Self numbers: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: ditto, removed unnecessary return) |
m (→first 50 self numbers: added/changed whitespace and comments.) |
||
Line 997: | Line 997: | ||
parse arg n . /*obtain optional argument from the CL.*/ |
parse arg n . /*obtain optional argument from the CL.*/ |
||
if n=='' | n=="," then n= 50 /*Not specified? Then use the default.*/ |
if n=='' | n=="," then n= 50 /*Not specified? Then use the default.*/ |
||
@.= |
@.= . /*initialize the array of self numbers.*/ |
||
do j=1 for n*10 /*scan through ten times the #s wanted.*/ |
do j=1 for n*10 /*scan through ten times the #s wanted.*/ |
||
$= j /*1st part of sum is the number itself.*/ |
$= j /*1st part of sum is the number itself.*/ |
||
Line 1,005: | Line 1,005: | ||
@.$= /*mark J as not being a self number. */ |
@.$= /*mark J as not being a self number. */ |
||
end /*j*/ |
end /*j*/ |
||
list= 1 /*initialize list to the |
list= 1 /*initialize the list to the 1st number*/ |
||
#= 1 /*the count of self numbers (so far). */ |
|||
do i=3 until #==n; if @.i=='' then iterate /*Not a self number? Then skip it. */ |
|||
#= # + 1; list= list i /*bump counter of self #'s; add to list*/ |
|||
⚫ | |||
#= # + 1 /*bump the counter of self numbers. */ |
|||
list= list i /*append it to the list of self numbers*/ |
|||
⚫ | |||
say 'the first ' n " self numbers are:" |
say 'the first ' n " self numbers are:" /*display the title for the output list*/ |
||
say list /*display list of self numbers ──►term.*/ |
say list /*display list of self numbers ──►term.*/ |
||
exit 0 /*stick a fork in it, we're all done. */</lang> |
exit 0 /*stick a fork in it, we're all done. */</lang> |