fork download
  1. def next_perfect(n):
  2. total=0
  3. for d in range(1, n):
  4. if n%d==0:
  5. total=total+d
  6. if total==n:
  7. return n
  8. else:
  9. return next_perfect(n+1)
  10.  
  11. print(next_perfect(500))
Runtime error #stdin #stdout #stderr 0.17s 23744KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 11, in <module>
  File "./prog.py", line 9, in next_perfect
  File "./prog.py", line 9, in next_perfect
  File "./prog.py", line 9, in next_perfect
  [Previous line repeated 994 more times]
  File "./prog.py", line 3, in next_perfect
RecursionError: maximum recursion depth exceeded in comparison