Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created August 4, 2014 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shohan4556/b21585d0c55344fa7f8a to your computer and use it in GitHub Desktop.
Save shohan4556/b21585d0c55344fa7f8a to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
int i,n,x;
printf("Enter a positive number to check prime");
scanf("%d",&n);
x = sqrt(n);
for(i=2;i<=x;i++)
{
if(n%i==0)
break;
}
if(n>1 && i == x+1)
printf(“This is a prime number”);
else
printf(“This isn’t a prime number”);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment