Self numbers: Difference between revisions

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