Previous Next
0 / 15
Module DEMO-33-67DEMO-OOP-33

Count Digit Seven using while

DEMO-OOP-33 • Object Oriented Programming

Browser-only practice

Problem Statement

Write a program that counts how many times the digit 7 appears in a given non-negative integer.

For example, in the number 752717, the digit 7 appears 3 times (at positions 1, 4, and 6 from the right, 0-indexed).

Your program should read one integer from standard input and output the count of digit 7 occurrences.

Constraints

0 ≤ N ≤ 10^18 The input will fit in a 64-bit signed integer type

Input Format

A single line containing a non-negative integer N (0 ≤ N ≤ 10^18).

Output Format

A single integer representing the number of times digit 7 appears in N.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
752717
3
Sample case: 7 appears at positions 0, 3, and 5 (from right to left, 0-indexed)
Sample #2
Public sample
123456
0
No occurrence of digit 7
Sample #3
Public sample
0
0
Zero contains no 7s
Sample #4
Public sample
987654321
1
Only one occurrence of digit 7
Sample #5
Public sample
7
1
Single digit 7
Sample #6
Public sample
7799
2
Large number with 7s at the beginning

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings