Perfect numbers: Difference between revisions
Content added Content deleted
m (→optimized using only even numbers: added whitespace for the head of a DO loop .) |
m (→Lucas-Lehmer + other optimizations: added a comment for the "Lucus'" numbers.) |
||
Line 1,607: | Line 1,607: | ||
w=length(high) /*use W for formatting output. */ |
w=length(high) /*use W for formatting output. */ |
||
numeric digits max(9,w+2) /*ensure enough digits to handle#*/ |
numeric digits max(9,w+2) /*ensure enough digits to handle#*/ |
||
@.=0; @.1=2; !.=2; _=' 6' |
@. =0; @.1=2; !.=2; _=' 6' /*highest magic # and its index.*/ |
||
!._=22; !.16=12; !.28=8; !.36=20; !.56=20; !.76=20; !.96=20 |
!._=22; !.16=12; !.28=8; !.36=20; !.56=20; !.76=20; !.96=20 |
||
/* [↑] "Lucas' numbers, 1891. */ |
|||
do i=low to high by 0 /*process the single # or range. */ |
do i=low to high by 0 /*process the single # or range. */ |
||
if isPerfect(i) then say right(i,w) 'is a perfect number.' |
if isPerfect(i) then say right(i,w) 'is a perfect number.' |