write an algorithm and flowchart of weather a number is a prime number or not
Answers
An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English rather than within the programming language
A sequential solution of any program that written in human language, called algorithm.
Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem.
Pseudo code
Input N and M
While N is smaller than M
Initialize I to 2
While I is smaller than N
If N is divisible by I
skip loop
Increment I
If N is equal to I
Print N
Increment N
Detailed Algorithm:
Step 1: Input N & M
Step 2: While (N < M)
I=2
Step 4: While (I<N)
Step 5: IF N%I == 0
goto Step 7
Step 6: I++
Step 7: IF I==NUM
Print NUM
Step 7: N++
Flowchart:-
FlowChart_Prime_Rg
Answer:
1]input number N
↓
2]divide N by 2
↓
3]if remainder = 0 yes→ N is a prime number
No
↓
4]N is not a prime number