Last active
August 29, 2015 14:19
-
-
Save MarshallOfSound/b03ed5333dcb6337dfc2 to your computer and use it in GitHub Desktop.
Square sum problem
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 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