Created
February 22, 2018 13:05
-
-
Save programmingfaster0226/a1383f3d4b6fff18e0c588fec6400de7 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> | |
#include<conio.h> | |
int primeno(int, int); | |
int main() | |
{ | |
int num,c; | |
printf("Enter a number: "); | |
scanf("%d", &num); | |
c= primeno(num, num / 2); | |
if (c == 1) | |
{ printf("%d is a prime number\n", num);} | |
else | |
{printf("%d is not a prime number\n", num);} | |
getch(); | |
return 0; | |
} | |
int primeno(int num, int i) | |
{ | |
if (i == 1) | |
{return 1;} | |
else | |
{if (num % i == 0) | |
{return 0; } | |
else | |
{return primeno(num, i - 1);} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment