Description
This problem is a programming version of Problem 36 from projecteuler.net
The decimal number, 585=10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than N, which are palindromic in base 10 and base K.
Input Format
Input contains two integers N and K.
Output Format
Print the answer corresponding to the test case.
Constraints
10≤N≤106
2≤K≤9
Sample Input
Sample Output




Reviews
There are no reviews yet.