Skip to content

Instantly share code, notes, and snippets.

@MarshallOfSound
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarshallOfSound/b03ed5333dcb6337dfc2 to your computer and use it in GitHub Desktop.
Save MarshallOfSound/b03ed5333dcb6337dfc2 to your computer and use it in GitHub Desktop.
Square sum problem
def square_sum(n):
number = str(n);
i = 1;
while (i <= len(number)):
if (len(number) % i == 0):
start = 0;
sum = 0;
while (start + i <= len(number)):
sum += (int(number[start:(start+i)])) ** 2;
start += i;
if (sum == n):
return True;
i+=1;
return False;
print(square_sum(8833));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment