How to write a Program to find n primes after a given number? e.g. first 10 primes after 100, or first 25 primes after 1000. Edited: below is what I tried. I am getting output that way, but can we do it without using any primality-testing function?
#include<stdio.h>
#include<conio.h>
int isprime(int);
main()
{
int count=0,i;
for(i=100;1<2;i++)
{
if(isprime(i))
{
printf("%d\n",i);
count++;
if(count==5)
break;
}
}
getch();
}
int isprime(int i)
{
int c=0,n;
for(n=1;n<=i/2;n++)
{
if(i%n==0)
c++;
}
if(c==1)
return 1;
else
return 0;
}
printf()
needs a format specification for the integer, and probably a newline at the end too. – Gallia