Anonymous user
Perfect numbers: Difference between revisions
m
→optimized using only even numbers: changed indentations for the ISPERFECT function.
m (→Lucas-Lehmer method: added/changed comments and whitespace.) |
m (→optimized using only even numbers: changed indentations for the ISPERFECT function.) |
||
Line 1,808:
/*──────────────────────────────────────────────────────────────────────────────────────*/
isPerfect: procedure; parse arg x 1 y /*obtain the number to be tested. */
parse var y 1 r 2; do k=2 for length(y)-1;
do j=3 while j*j<=x
if x//j\==0 then iterate
'''output''' is the same as the traditional version and is about '''11.5''' times faster (testing 34,000,000 numbers).
|