Skip to content

Instantly share code, notes, and snippets.

@FottyM
Created January 13, 2018 21:59
Show Gist options
  • Save FottyM/d0d81385669ace84a8a538a048709902 to your computer and use it in GitHub Desktop.
Save FottyM/d0d81385669ace84a8a538a048709902 to your computer and use it in GitHub Desktop.
#include<stdio.h>
int is_prime(int num)
{
if (num <= 1) return 0;
if (num % 2 == 0 && num > 2) return 0;
for(int i = 3; i < num / 2; i+= 2)
{
if (num % i == 0)
return 0;
}
return 1;
}
int main()
{
int x, n;
printf("Enter x and n ");
scanf("%d %d", &x , &n);
for(int i = x+1; i<= x+n; i++ ){
if(is_prime(i)){
printf(" %d", i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment