Skip to content

Instantly share code, notes, and snippets.

@arikrak
Created February 8, 2013 20:20
Show Gist options
  • Save arikrak/4741665 to your computer and use it in GitHub Desktop.
Save arikrak/4741665 to your computer and use it in GitHub Desktop.
#adr2370's solution to Leibniz Challenge
#https://github.com/adr2370/HackerRankBackToSchool/blob/master/Leibniz.py
#193 characters
T=int(input())
for a in range(T):
n=int(input())
x=0.0
for i in range(n):
if i%2==0:
x+=1.0/(2*i+1)
else:
x-=1.0/(2*i+1)
print("%.15f"%x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment