A number that is divisible by 1 and itself only is called a Prime Number. For Example, 3, 5, 7, 11, 13, 17 and 19 are examples of Prime Numbers. 2 is the only even prime number.
Algorithm and Flowchart for prime number
Algorithm:
- Start
- Read Number n
- Set the value of i=2 (Initialize variables)
- If i<n then go to step 5 otherwise go to step 6
- If n%i ==0 then go to step 6
- Else, Increment the value of I by 1 and go to step 4.
- If i==n then
- Print “n is prime number”
- Else
- Print “n is not prime number”
- Stop
Flowchart: