too simple Python 3 #3 program
source code
# The Computer Language Benchmarks Game
# https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
import sys
def main():
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))
main()
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
Python 3.12.2
Mon, 04 Mar 2024 12:26:56 GMT
MAKE:
mv toosimple.python3-3.python3 toosimple.python3-3.py
pyright .
0 errors, 0 warnings, 0 informations
3.94s to complete and log all make actions
COMMAND LINE:
/opt/src/Python-3.12.2/bin/python3 -OO toosimple.python3-3.py 10000000000
PROGRAM OUTPUT:
3.141592654