Recursive prime number

Back

#include stdio.h
#include conio.h
#include assert.h

int is_prime(int n);

void main(void)
{
int n=0;
// clrscr();
printf("An integer ");
scanf("%d",&n);
assert(n > 1);
n=is_prime(n);
if (n==1)
printf("\nThe number is prime");
else
printf("\nThe number is not prime");
//getch();
}

int is_prime(int n)
{
int i;
for(i=2;i
if (n%i)
continue;
else return 0;
}
return 1;
}

No comments:

Post a Comment

There was an error in this gadget

Followers

About Me

Dhaka, Dhaka, Bangladesh
..