Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding "perfect" numbers
#3
this works for the first 5 but not sure how wise it is to use array for numbers larger than 4th perfect number (6,28,496,8128,33550336). best of luck to ya.
Function find_perfect_numbers2
Code:
Copy      Help
int sn cn ii fnc
sn=8128
ARRAY(int) pnc.create(sn)
cn=1
for ii cn sn
,if !(sn%cn)
,,pnc[ii]=cn
,,out pnc[ii]
,,fnc=fnc+pnc[ii]
,cn+1
fnc=fnc+sn/2
if fnc=sn
,out "perfect number"
else
,out "not pefect number"


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)