Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions

Added XPL0 example.
(→‎{{header|Raku}}: Add a Raku example)
(Added XPL0 example.)
Line 170:
 
Found 23 such numbers.
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func Reverse(N, Base); \Reverse order of digits in N for given Base
int N, Base, M;
[M:= 0;
repeat N:= N/Base;
M:= M*Base + rem(0);
until N=0;
return M;
];
 
int Count, N;
[Count:= 0;
for N:= 1 to 25000-1 do
if N = Reverse(N, 2) &
N = Reverse(N, 4) &
N = Reverse(N, 16) then
[IntOut(0, N);
Count:= Count+1;
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
];
CrLf(0);
IntOut(0, Count);
Text(0, " such numbers found.
");
]</lang>
 
{{out}}
<pre>
1 3 5 15 17 51 85 255 257 273
771 819 1285 1365 3855 4095 4097 4369 12291 13107
20485 21845
22 such numbers found.
</pre>
772

edits