Algorithm to check if the number is prime or not

1. Start.

2. Read the number.

3. Initialize i=2 , count=0.

4. While(i<=number/2)
       If number % i==0 ,
                            then increment count by 1.
       Increment i by 1.

5. If count==0, then the number is prime.
    Else the number is not prime.

6.End.

No comments:

Post a Comment