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 #145: How many reversible numbers are there below one-billion?

Project Euler #145: How many reversible numbers are there below one-billion?

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 145 from projecteuler.net

Some positive integers have the property that the sum consists entirely of odd (decimal) digits. For instance, and . We will call such numbers reversible; so , , , and are reversible. Leading zeroes are not allowed in either or .

There are 120 reversible numbers below one-thousand.

Given , how many reversible numbers are there below ?

Input Format

The first line of input contains , the number of test cases.

Each test case consists of one line containing a single integer, .

Constraints

In test file #1:
In test file #2:
In test file #3:

Output Format

For each test case, output a single line containing a single integer, the number of reversible numbers below .

Sample Input

2
1000
948

Sample Output

120
119

Explanation

As mentioned in the problem statement, there are reversible numbers below , the largest of which is .

Author

kevinsogo

Difficulty

Hard

Max Score

100

Submitted By

1738

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy