Anonymous user
Self numbers: Difference between revisions
m
→first 50 self numbers: added a feature to the program.
m (→first 50 self numbers: added/changed whitespace and comments.) |
m (→first 50 self numbers: added a feature to the program.) |
||
Line 997:
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)
@.= . /*initialize the array of self numbers.*/
do j=1 for n*10
$= j
do k=1 for length(j)
$= $ + substr(j, k, 1)
end /*k*/
@.$=
end /*j*/
list= 1 /*initialize the list to the 1st number*/
#= 1 /*the count of self numbers (so far). */
Line 1,011 ⟶ 1,012:
end /*i*/
say
exit 0 /*stick a fork in it, we're all done. */</lang>
{{out|output|text= when using the default input:}}
<pre>
1 3 5 7 9 20 31 42 53 64 75 86 97 108 110 121 132 143 154 165 176 187 198 209 211 222 233 244 255 266 277 288 299 310 312 323 334 345 356 367 378 389 400 411 413 424 435 446 457 468
</pre>
|