Last active
August 29, 2015 14:12
-
-
Save ebartrum/cba4fe5cebec90f85380 to your computer and use it in GitHub Desktop.
463 in progress
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
#Define the function f by recursion: | |
def f(n): | |
if n==1: | |
return 1 | |
if n==3: | |
return 3 | |
if n%2==0: | |
return f(n/2) | |
if (n-1)%4==0: | |
m=(n-1)/4 | |
return 2*f(2*m+1)-f(m) | |
if (n-3)%4==0: | |
m=(n-3)/4 | |
return 3*f(2*m+1)-2*f(m) | |
def s(n): | |
ans=0 | |
for m in xrange(1,n+1): | |
ans+=f(m) | |
return ans | |
print s(3**37) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment