Computer Science, asked by satyaram9384, 1 year ago

Write an algorithm to find a number is prime or not

Answers

Answered by Anonymous
1

Explanation:

Hey lovely frnd ...❤

Answer...✌

Brute force algorithm to check if a positive number P is prime.

Set N=2.

Divide P by

N and find the remainder R.

If R is zero, P is not prime. Exit.

Set N=N+1.

If N is greater than or equal P, P is Prime. Exit.

Go to step 2.

Hope it helps uuh

Happy Diwali in advance

Answered by Lily08
1

Answer:

1. Input number n.

2. If n<= 1, number is not prime and stop.

3. If n=2 , it is prime and stop.

4. Let I= 2

5. Repeat,

a) Divide n by I, if remainder is 0 then

isn't prime and stop

b) I = I + 1 until I <= N - 1

6. Stop

Similar questions