Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding "perfect" numbers
#6
last post on this.
This will do the first 8 and would do more if had a large enough number range, but can only do the first 8
;Perfect Number = 2^(n-1) * (2^n - 1)
out
ARRAY(str) mpn
mpn="2[]3[]5[]7[]13[]17[]19[]31[]61[]89[]107[]127[]521[]607[]1279[]2203[]2281[]3217[]4253[]4423[]9689[]9941[]11213[]19937[]21701[]23209[]44497[]86243[]110503[]132049[]216091[]756839[]859433[]1257787[]1398269"
long n i x
for i 0 8;; number goes out of range after 8.
,n=val(mpn[i])
,x=pow(2 (n-1)) * (pow(2 n)-1)
,out x

;;output
;;6
;;28
;;496
;;8128
;;33550336
;;8589869056
;;137438691328
;;2305843008139952128

wont show the whole ARRAY here.The rest of it after 86243 is
[]110503[]132049[]216091[]756839[]859433[]1257787[]1398269"
but really only need up to 31 after that number is too big


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)