Previous Next
0 / 20
Module DEMO-32-59DEMO-C-32

FizzBuzz Counter using for

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Write a program that counts how many numbers from 1 to N (inclusive) are divisible by both 3 and 5.

A number is divisible by both 3 and 5 if and only if it is divisible by 15. For example, between 1 and 30, the numbers divisible by both 3 and 5 are: 15 and 30, so the count is 2.

Your program should read a single integer N and output the count of numbers divisible by both 3 and 5 in the range [1, N].

Input Format

A single line containing one integer N (1 ≤ N ≤ 10^9).

Output Format

A single line containing one integer representing the count of numbers between 1 and N (inclusive) that are divisible by both 3 and 5.

Sample Testcases

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

Sample #1
Public sample
15
1
Only 15 is divisible by both 3 and 5 in the range [1, 15].
Sample #2
Public sample
30
2
Both 15 and 30 are divisible by both 3 and 5 in the range [1, 30].
Sample #3
Public sample
1
0
No numbers between 1 and 1 are divisible by both 3 and 5.
Sample #4
Public sample
1000000000
66666666
For large N, the count is simply N divided by 15 (integer division).

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