Skip to content

Instantly share code, notes, and snippets.

@lilpolymath
Created April 18, 2020 23:27
Show Gist options
  • Save lilpolymath/3041b4323474ac75df8703a0b1561875 to your computer and use it in GitHub Desktop.
Save lilpolymath/3041b4323474ac75df8703a0b1561875 to your computer and use it in GitHub Desktop.
Perfect Number
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)
@lilpolymath
Copy link
Author

I know right.

@lilpolymath
Copy link
Author

Any other thing? Before Michael roasts me alive.

@Youngestdev
Copy link

So we just had to start looping from the second variable lol.

@Youngestdev
Copy link

Lmaoooooooooo. Dazzal, you & michael. Let me be your students. Later brov

@lilpolymath
Copy link
Author

It has an issue with 0 because of the long long int type.

@Youngestdev
Copy link

Oh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment