Find palindromic numbers in both binary and ternary bases: Difference between revisions

m
Line 261:
=={{header|Ruby}}==
This program is based on the observation that the double palindromic numbers in base 3 all have a "1" right in the middle. Also, both base 2 and base 3 representations have an odd number of digits. (NB I have no mathematical proof of this).
This program constructs possible palindromes using the above "rules" and checks if they happen to be the same number.
The first six took less then one second, 381920985378904469 took around 40 minutes (using one core) and 146 million possible candidates.
<lang ruby>
1,149

edits