Created
April 14, 2020 19:10
-
-
Save ahmed4end/77621e90bac9d7f897172c50bd562510 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def sum_of_squares(n, f=1): | |
if n<0:return None | |
if n==0:return [] | |
start = n-1 if f else n | |
for j in range(start,0,-1): | |
if j**0.5 == int(j**0.5): | |
hold = sum_of_squares(n-j, f=0) | |
if hold !=None:return hold + [j] | |
print(sum_of_squares(16)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment