#208. 递归计数数字出现次数
递归计数数字出现次数
Count Digit 7
Background
Congcong is currently studying the properties of numbers. He has discovered that some numbers contain specific digits, such as the digit 7. He wants to know how many times the digit 7 appears in a given non-negative integer.
Problem Description
Given a non-negative integer , return the count of occurrences of the digit 7. For example, for , the result is 2. Please note that loops are not allowed in this problem. Hint: Modulo () by 10 yields the rightmost digit (e.g., is ), while integer division () by 10 removes the rightmost digit (e.g., is ).
Input Format
Input is given from standard input in the following format.
A non-negative integer .
Output Format
Output is printed to standard output in the following format.
The count of occurrences of the digit 7.
Sample
717
2
7
1
123
0
Sample Explanation
For Sample 1, the digit 7 appears twice in . For Sample 2, the digit 7 appears once in . For Sample 3, the digit 7 does not appear in .
Constraints
Time limit: 1 second, Memory limit: 1024 KiB for each test case.