Created
August 16, 2014 19:33
-
-
Save davidawad/7cbc863b9f111321d0da to your computer and use it in GitHub Desktop.
Solutions for the Leibniz Challenge on Hackerrank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec"print'%.15g'%sum((-1.)**i/(i-~i)for i in range(input()));"*input() | |
##python 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment