Skip to content

Instantly share code, notes, and snippets.

@ahmed4end
Created April 14, 2020 19:10
Show Gist options
  • Save ahmed4end/77621e90bac9d7f897172c50bd562510 to your computer and use it in GitHub Desktop.
Save ahmed4end/77621e90bac9d7f897172c50bd562510 to your computer and use it in GitHub Desktop.
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