defperfect_number(num):su=0foriinrange(1,num):ifnum%i==0:su+=ireturnsu==numdefperfect_number_main(n):ifperfect_number(n)==True:print("%s is perfect"%n)else:passforiinrange(1,10000):perfect_number_main(i)
defsum_divisions(n)(1...n).select{|i|n%i==0}.sumenddefperfect_number?(n)n==sum_divisions(n)end(1..10_000).eachdo|i|puts"#{i} is perfect"ifperfect_number?(i)end
I'm Jake Cahill. Lifetime Pythonista, web scraping and automation expert. Enjoy books. Love my wife, dog, and cat, and think AI and Julia are pretty nifty
Location
Maine, USA
Education
A Master's patient mentorship and insatiable curiosity
I wrote this script 3 years ago.
Translate yours in Ruby.
In JS, not so good cause I'm new to JS. If any good writing comment please.
Do you have a better version for Go?
How efficient do you remember this article being?