Spread the post

check prime number in c

Prime number is a number there are divisible by itself value and number 1.

Given two solution of this problem.

1) using recursion (without using any Loop)

2) using iterative (using loop)

1) Using recursion

program to check prime number in c using recursion

Output

View execution process.

Stack Areamainnumber (int) =11primedivide (int) =5number (int) =11primedivide (int) =4number (int) =11primedivide (int) =3number (int) =11primedivide (int) =2number (int) =11primedivide (int) =1number (int) =11

Try it yourself

2) Using loop

Program to check prime number in c using while loop.

Try it yourself

Output

Spread the post

Recommended Posts: