WAP to input a number and check if it is prime.
pls help.
Answers
Answered by
3
Answer:
If any number smaller than the given number divides it then it is not Prime number. Otherwise, it is a prime number. Let's take an example of two numbers and check whether they are prime or not using this process. Logic − We will divide 42 by every number greater than 1 and smaller than 42
Explanation:
Answered by
1
Answer:
Program to Check Prime Number
In the program, a for loop is iterated from i = 2 to i < n/2 . If n is perfectly divisible by i , n is not a prime number. In this case, flag is set to 1, and the loop is terminated using the break statement. After the loop, if n is a prime number, flag will still be 0.
Explanation:
please follow me.
Similar questions
Science,
3 months ago
English,
3 months ago
Hindi,
3 months ago
English,
6 months ago
English,
6 months ago
CBSE BOARD X,
11 months ago
Political Science,
11 months ago
Geography,
11 months ago