Project Euler [Problem 36]

時が経つのは超早い

ぼちぼち。

問題

Double-base palindromes

The decimal number, 585 = 1001001001_2 (binary), is palindromic in both bases.

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

(Please note that the palindromic number, in either base, may not include leading zeros.)

私訳

2基数回文数

10進数 585 は 2進表記で 1001001001_2 であり、どちらの基数でも回文である。

100万未満の数のうち、基数10および2両方で回文数となるものの和を求めよ

(回文数かどうか判断する際には上位桁のゼロを無視することに注意)

解答方針

単純に、10進と2進の両方で回文数か判断すればいいだろう