Previous Next
0 / 18
Module DEMO-32-91DEMO-C-32

First Prime Number Finder

DEMO-C-32 β€’ Programming in C

Browser-only practice

Problem Statement

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, consider the range [10, 20]. The first prime number within this range is 11.

Write a program that reads two integers β€” a start and an end of a range β€” and finds the first prime number within that range.If a prime number is found, print it and stop checking the rest of the numbers.If no prime number is found in the range, print "No prime number found".

Hint: Use break inside the loop when:Checking if a number is not prime β†’ break inner loop.Finding the first prime β†’ break outer loop.

Constraints

Constraints:- The input integers are within the valid range [1, 1000].

Input Format

Input Format:- Two space-separated integers representing the start and end of a range (inclusive). For example: 10 20

Output Format

Output Format:The first prime number found in the range. If no prime number is found, print "No prime number found".

Sample Testcases

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

Sample #1
Public sample
10 20
11
Sample #2
Public sample
24 28
No prime number found

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