Jump to content

Kaprekar numbers: Difference between revisions

m
→‎{{header|REXX}}: changed a comment (box), changed output section title.
m (→‎Numeric version (medium): added '.race' for concurrency)
m (→‎{{header|REXX}}: changed a comment (box), changed output section title.)
Line 3,907:
=={{header|REXX}}==
<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, ║
║ Shri Dattathreya Ramachardra Kaprekar (1905 ───► 1986). ║
╚═══════════════════════════════════════════════════════════════════╝ ╚═══════════════════════════════════════════════════════════════════╝*/
parse arg A B . /*obtain optional arguments from the CL*/
if A=='' | A="," then A= 10000 /*Not specified? Then use the default.*/
Line 3,922:
if aN>0 then call tell 1 /*unity is defined to be a Kaprekar #. */
/* [↑] handle case of N being unity.*/
if aN>1 then do j=29 for aN-29; 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?*/
parse var s L +(k) R
Line 3,933:
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell: #=#+1; if N>0 then say right(arg(1), digits()); return /*maybe display it*/</lang>
'''{{out|output''' |text=&nbsp; when using the default inputs of: &nbsp; &nbsp; <tt> &nbsp; 10000 &nbsp; -1000000 </tt>}}
<pre>
1
Cookies help us deliver our services. By using our services, you agree to our use of cookies.