Casting out nines: Difference between revisions

Added XPL0 example.
No edit summary
(Added XPL0 example.)
Line 2,121:
 
[1, 16, 17, 32, 33, 48, 49, 64, 65, 80, 81, 96, 97, 112, 113, 128, 129, 144, 145, 160, 161, 176, 177, 192, 193, 208, 209, 224, 225, 240, 241, 256, 257, 272, 273, 288]
</pre>
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">include xpllib;
 
def N = 2.;
int Base, C1, C2, K;
\int Main\ [
Base:= 10; C1:= 0; C2:= 0;
for K:= 1 to fix(Pow(float(Base), N)) - 1 do [
C1:= C1+1;
if rem(K/(Base-1)) = rem((K*K)/(Base-1)) then [
C2:= C2+1;
Print("%d ", K);
]
];
 
Print("\nTrying %d numbers instead of %d numbers saves %1f%%\n",
C2, C1, 100.0 - 100.0*float(C2)/float(C1));
return 0;
]</syntaxhighlight>
{{out}}
<pre>
1 9 10 18 19 27 28 36 37 45 46 54 55 63 64 72 73 81 82 90 91 99
Trying 22 numbers instead of 99 numbers saves 77.77778%
</pre>
=={{header|zkl}}==
291

edits