Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding "perfect" numbers
#4
tweaked it a little array only populated now with the exact amount of elements it needs to hold divisor numbers.
Function find_perfect_numbers3
Code:
Copy      Help
int sn cn ii fnc i
sn=1500000
ARRAY(int) pnc
cn=1
for ii cn sn
,if !(sn%cn)
,,pnc[]=cn
,,out pnc[i]
,,fnc=fnc+pnc[i]
,,i+1
,cn+1
fnc=fnc+sn/2
if fnc=sn
,out "perfect number"
else
,out "not pefect number"

You May have to change array type as u get into larger numbers though.but this is not the best way to test either and is limited in how far it can go.
http://www.mersenne.org/ has software just for doing this


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)