Created
May 29, 2020 04:53
-
-
Save wasit-shafi/8c51fca47feaf5e67a80fef401619671 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 isPrime(int n , int i) | |
{ | |
if(n < 2) return 0; | |
if(n == 2) return 1; | |
if(n % i == 0) return 0; | |
if(i * i > n) return 1; | |
isPrime(n, i + 1); | |
} | |
int main() | |
{ | |
int n; | |
printf("Enter Value of n... "); | |
scanf("%d", &n); | |
if(isPrime(n, 2)) | |
printf("%d is a Prime Number.", n); | |
else | |
printf("%d is not a Prime Number.", n); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment