A program to find the number of times digit 3 occurs in each and every number from 0 to n is discussed here. Given a number n as input, count the number of 3s occurring in all the numbers from 0 to n.
For example,
Input: 100
Output: 20
The total number of 3s that appear from numbers 0 to 100 are {3, 13, 23, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 53, 63, 73, 83, 93}
The program to find the number of times digit 3 occurs in each and every number from 0 to n is given below.
@@coding::1@@
Time complexity: O(n)
Recommended Programs