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.*/
@.= . /*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 first number. */
list= 1 /*initialize the list to the 1st number*/
#= 1 /*the count of self numbers (so far). */
#= 1 /*the count of self numbers (so far). */
do i=3 until #==n /*traipse through array 'til satisfied.*/
do i=3 until #==n; if @.i=='' then iterate /*Not a self number? Then skip it. */
if @.i=='' then iterate /*Not a self number? Then skip it. */
#= # + 1; list= list i /*bump counter of self #'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 '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>