Count the numbers
Submissions: 6458   Accuracy:

34.46%

  Difficulty: Basic   Marks: 1

Given a number N, count the numbers from 1 to N which comprise of digits, only in set 1, 2, 3, 4 and 5

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consist of one line. Each line of each test case is N, where N is the range from 1 to N.

Output:
Print the count of numbers in the given range from 1 to N.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 103

Example:

Input:
2
100
10
Output:
30
5

Explanation:
When N is 20 then answer is 10 because 1 2 3 4 5 11 12 13 14 15 are only in given set. 16 is not beause 6 is not in given set, only 1 2 3 4 5 in set.

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.