Numbers in base 10 that are palindromic in bases 2, 4, and 16: Difference between revisions
Numbers in base 10 that are palindromic in bases 2, 4, and 16 (view source)
Revision as of 06:55, 27 June 2021
, 3 years ago→{{header|Julia}}
Line 342:
Found 23 such numbers.
</pre>
=={{header|Julia}}==
<lang julia>palinbases(n, bases = [2, 4, 16]) = all(b -> (d = digits(n, base = b); d == reverse(d)), bases)
foreach(p -> print(rpad(p[2], 7), p[1] % 11 == 0 ? "\n" : ""), enumerate(filter(palinbases, 1:25000)))
</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
</pre>
|