We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #36: Double-base palindromes

# Project Euler #36: Double-base palindromes

# Project Euler #36: Double-base palindromes

_{This problem is a programming version of Problem 36 from projecteuler.net}

The decimal number, (binary), is palindromic in both bases.

Find the sum of all natural numbers, less than , which are palindromic in base and base .

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

**Input Format**

Input contains two integers and .

**Constraints**

**Output Format**

Print the answer corresponding to the test case.

**Sample Input**

```
10 2
```

**Sample Output**

```
25
```

**Explanation**

These numbers are palindromic in their decimal as well as base representation: . Their sum is