#208. 递归计数数字出现次数

    ID: 208 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归

递归计数数字出现次数

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 nn, return the count of occurrences of the digit 7. For example, for n=717n=717, the result is 2. Please note that loops are not allowed in this problem. Hint: Modulo (n(mod10)n \pmod{10}) by 10 yields the rightmost digit (e.g., 126(mod10)126 \pmod{10} is 66), while integer division (n/10n / 10) by 10 removes the rightmost digit (e.g., 126/10126 / 10 is 1212).

Input Format

Input is given from standard input in the following format.

A non-negative integer nn.

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 717717. For Sample 2, the digit 7 appears once in 77. For Sample 3, the digit 7 does not appear in 123123.

Constraints

Time limit: 1 second, Memory limit: 1024 KiB for each test case.