The Computer Language
24.04 Benchmarks Game

too simple Python 3 program

source code

# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/

import sys 

n = int(sys.argv[1])
sum = 0.0
flip = -1.0
for i in range(1,n):    
    flip *= -1.0        
    sum += flip / (2*i - 1)                                      
print("%.9f" % (sum*4.0))
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
Python 3.12.2


 Mon, 04 Mar 2024 12:56:04 GMT

MAKE:
mv toosimple.python3 toosimple.py
pyright .
0 errors, 0 warnings, 0 informations 

3.93s to complete and log all make actions

COMMAND LINE:
 /opt/src/Python-3.12.2/bin/python3 -OO toosimple.py 10000000000

PROGRAM OUTPUT:
3.141592654