too simple Python 3 #3 program
source code
# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
import sys
def main():
# mtime side-effect
with open( './one', 'w') as f: pass
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))
# mtime side-effect
with open( './two', 'w') as f: pass
main()
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
Python 3.13.0
Sat, 12 Oct 2024 20:39:08 GMT
MAKE:
mv toosimple.python3-3.python3 toosimple.py
pyright .
0 errors, 0 warnings, 0 informations
4.64s to complete and log all make actions
COMMAND LINE:
/opt/src/Python-3.13.0/bin/python3 -OO toosimple.py 10000000000
PROGRAM OUTPUT:
3.141592654