### pi to specified precision python

pi value using python

use python test.py 100

https://www.w3resource.com/projects/python/python-projects-1.php

PI:  3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

#!/usr/bin/python3
# Calculate PI number using this formula:
# x[n+1] = x[n] + sin(x[n])
#
# x[n+1] = x[n] + x[n] + x[n]**3/fact(3) - x[n]**5/fact(5) + x[n]**7/fact(7) - x[n]**9/fact(9) + ....

from decimal import getcontext, Decimal
import sys

if len(sys.argv) < 2:
print('Not enough arguments')
quit()

precision = int(sys.argv[1])
excess_prec = 2

prec_cur = 100 if precision > 100 else precision

getcontext().prec = prec_cur + excess_prec

second = Decimal(3) # Current element for PI
queue_cur = [Decimal(0), Decimal(0), Decimal(0), second]

qq_append = queue_cur.append
qq_pop = queue_cur.pop

limit = Decimal(10) ** (-prec_cur - excess_prec)

while True:

sec_sq = second * second
term = second
acc = second + term
count = Decimal(1)

while term > limit:

term *= sec_sq / ((count + 1) * (count + 2))
acc -= term
# print ('term1: {}'.format(term))

term *= sec_sq / ((count + 3) * (count + 4))
acc += term

count += 4
# print ('term2: {}'.format(term))

# print ('acc: {}'.format(second))
if acc in queue_cur:
if prec_cur < precision:
prec_cur += prec_cur
if prec_cur > precision:
prec_cur = precision
limit = Decimal(10) ** (-prec_cur - excess_prec)
getcontext().prec = prec_cur + excess_prec

else:
second = acc
break

qq_append(acc)
qq_pop(0)
second = acc
# print ('second: {}'.format(second))

getcontext().prec = precision
print("PI: ", +second)

### sxhkd volume andbrightness config for dwm on void

xbps-install  sxhkd ------------ mkdir .config/sxhkd cd .config/sxhkd nano/vim sxhkdrc -------------------------------- XF86AudioRaiseVolume         amixer -c 1 -- sset Master 2db+ XF86AudioLowerVolume         amixer -c 1 -- sset Master 2db- XF86AudioMute         amixer -c 1 -- sset Master toggle alt + shift + Escape         pkill -USR1 -x sxhkd XF86MonBrightnessUp          xbacklight -inc 20 XF86MonBrightnessDown          xbacklight -dec 20 ------------------------------------------------------------- amixer -c card_no -- sset Interface volume run alsamixer to find card no and interface names xbps-install -S git git clone https://git.suckless.org/dwm xbps-install -S base-devel libX11-devel libXft-devel libXinerama-devel  vim config.mk # FREETYPEINC = \${X11INC}/freetype2 #comment for non-bsd make clean install   cp config.def.h config.h vim config.h xbps-install -S font-symbola #for emoji on statusbar support     void audio config xbps-i