Created
April 18, 2020 23:27
-
-
Save lilpolymath/3041b4323474ac75df8703a0b1561875 to your computer and use it in GitHub Desktop.
Perfect Number
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 solve(number): | |
sum = 0 | |
middle = int(number/2) + 1 | |
for i in range(1,middle): | |
if number%i == 0: | |
sum += i | |
if sum == number: | |
return sum | |
if __name__ == "__main__": | |
rangeTo = int(input()) | |
perfect = [] | |
for i in range(rangeTo + 1): | |
number = solve(i) | |
if number: | |
perfect.append(number) | |
print(perfect) | |
I know right.
Any other thing? Before Michael roasts me alive.
So we just had to start looping from the second variable lol.
Lmaoooooooooo. Dazzal, you & michael. Let me be your students. Later brov
It has an issue with 0 because of the long long int type.
Oh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See difference lol.