Kaprekar numbers: Difference between revisions

Content added Content deleted
m (→‎Numeric version (medium): added '.race' for concurrency)
m (→‎{{header|REXX}}: changed a comment (box), changed output section title.)
Line 3,907: Line 3,907:
=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX pgm generates & counts (+ maybe shows) some Kaprekar #s using the cast─out─9 test*/
<lang rexx>/*REXX pgm generates & counts (+ maybe shows) some Kaprekar #s using the cast─out─9 test*/
/* ╔═══════════════════════════════════════════════════════════════════╗
/*╔═══════════════════════════════════════════════════════════════════╗
║ Kaprekar numbers were thought of by the mathematician from India, ║
║ Kaprekar numbers were thought of by the mathematician from India, ║
║ Shri Dattathreya Ramachardra Kaprekar (1905 ───► 1986). ║
║ Shri Dattathreya Ramachardra Kaprekar (1905 ───► 1986). ║
╚═══════════════════════════════════════════════════════════════════╝ */
╚═══════════════════════════════════════════════════════════════════╝*/
parse arg A B . /*obtain optional arguments from the CL*/
parse arg A B . /*obtain optional arguments from the CL*/
if A=='' | A="," then A= 10000 /*Not specified? Then use the default.*/
if A=='' | A="," then A= 10000 /*Not specified? Then use the default.*/
Line 3,922: Line 3,922:
if aN>0 then call tell 1 /*unity is defined to be a Kaprekar #. */
if aN>0 then call tell 1 /*unity is defined to be a Kaprekar #. */
/* [↑] handle case of N being unity.*/
/* [↑] handle case of N being unity.*/
if aN>1 then do j=2 for aN-2; s=j*j /*calculate the square of J (S). */
if aN>1 then do j=9 for aN-9; s=j*j /*calculate the square of J (S). */
if j//9==s//9 then do k=1 for length(s)%2 /*≡ casted out 9's?*/
if j//9==s//9 then do k=1 for length(s)%2 /*≡ casted out 9's?*/
parse var s L +(k) R
parse var s L +(k) R
Line 3,933: Line 3,933:
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell: #=#+1; if N>0 then say right(arg(1), digits()); return /*maybe display it*/</lang>
tell: #=#+1; if N>0 then say right(arg(1), digits()); return /*maybe display it*/</lang>
'''output''' &nbsp; when using the default inputs of: &nbsp; <tt> &nbsp; 10000 &nbsp; 1000000 </tt>
{{out|output|text=&nbsp; when using the default inputs of: &nbsp; &nbsp; <tt> &nbsp; 10000 &nbsp; -1000000 </tt>}}
<pre>
<pre>
1
1