Anonymous user
Aliquot sequence classifications: Difference between revisions
m
→{{header|REXX}}: changed an array name, changed a comment.
m (→{{header|REXX}}: ussed the uppercase version of a REXX variable.) |
m (→{{header|REXX}}: changed an array name, changed a comment.) |
||
Line 594:
big=2**47; NTlimit=16+1 /*limit: non-terminating*/
numeric digits max(9, 1+length(big)) /*be able to handle // */
say center('numbers from ' low " to " high, 79, "═")
Line 617:
/*──────────────────────────────────CLASSIFY_ALIQUOT subroutine─────────*/
classify_aliquot: parse arg a 1 aa; a=abs(a) /*get what # to be used.*/
if
else s=
what='terminating' /*assume this classification kind*/
c.=0; c.s=1 /*clear all cyclic seqs, set 1st.*/
Line 625:
else do t=1 while s\==0 /*loop until sum isn't 0 or >big.*/
m=word($, words($)) /*obtain the last number in seq. */
if
else s=
if m==s & m\==0 then do; what='aspiring' ; leave; end
if word($,2)==a then do; what='amicable' ; leave; end
Line 641:
/*──────────────────────────────────SHOW_CLASS subroutine───────────────*/
show_class: say right(arg(1),digits()) 'is' center(what,15) arg(2); return
/*──────────────────────────────────SIGMA subroutine────────────────────*/
s=1 /* [↓] use only EVEN|ODD integers*/
do j=2+odd by 1+odd while j*j<x /*divide by all integers up to √x*/
Line 649:
/* [↓] adjust for square. _ */
if j*j==x then s=s+j /*Was X a square? If so, add √x.*/
return s /*return
'''output''' when using the default input:
<pre>
|