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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #36: Double-base palindromes

Project Euler #36: Double-base palindromes

Problem
Submissions
Leaderboard
Discussions

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

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

3966

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy