davidawad
8/16/2014 - 7:33 PM

Solutions for the Leibniz Challenge on Hackerrank

Solutions for the Leibniz Challenge on Hackerrank

exec"print'%.15g'%sum((-1.)**i/(i-~i)for i in range(input()));"*input()


##python 2
from decimal import *
for x in range (0,int(input())):
    s,n=Decimal('0'),int(input())
    for i in range(0,n):
        s+= Decimal(str(((-1)**i)/((2*i)+1)))
    print (s)


##python 3