Last active
August 29, 2015 14:04
-
-
Save shohan4556/772926b4f31ac33a03e1 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