Anonymous user
Self numbers: Difference between revisions
m
→first 50 self numbers: added/changed whitespace and comments.
m (→{{header|AppleScript}}: Edited comments to show limit of accuracy. Changed the indexDiff calculation to reflect what it means (but same results). Added another demo.) |
m (→first 50 self numbers: added/changed whitespace and comments.) |
||
Line 996:
=={{header|REXX}}==
=== first 50 self numbers ===
<lang rexx>/*REXX program displays N self numbers
parse arg n . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n= 50 /*Not specified? Then use the default.*/
tell = n>0; n= abs(n) /*TELL: show the self numbers if N>0 */
@.= . /*initialize the array of self numbers.*/
do k=1 for length(j) /*sum the decimal digits in the number.*/
$= $ + substr(j, k, 1) /*add a particular digit to the sum. */
end /*k*/
list= 1 /*initialize the list to the 1st number*/
#= 1 /*the count of self numbers (so far). */
Line 1,013:
#= # + 1; list= list i /*bump counter of self #'s; add to list*/
end /*i*/
say
if tell then say list /*display list of self numbers ──►term.*/</lang>
▲exit 0 /*stick a fork in it, we're all done. */</lang>
{{out|output|text= when using the default input:}}
<pre>
|