You are viewing a single comment's thread. Return to all comments →
i am not getting answerdef fn(n) : if (n == 0) or (n == 1): return n;
elif (n % 2 == 0): #even return fn(n / 2); elif (n % 2 == 1): #odd return fn((n-1) / 2) + fn((n+1) / 2); return -1
num = int(input()) print(int(fn(num+1)))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #169: Exploring the number of different ways a number can be expressed as a sum of powers of 2.
You are viewing a single comment's thread. Return to all comments →
i am not getting answerdef fn(n) : if (n == 0) or (n == 1): return n;
num = int(input()) print(int(fn(num+1)))