Created
August 4, 2014 04:43
-
-
Save shohan4556/3675b5b9f9efd25945d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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