Last active
December 30, 2015 07:09
-
-
Save ahmetilhann/7794496 to your computer and use it in GitHub Desktop.
Girilen bir sayıdan büyük en küçük asal sayıyı hesaplama
This file contains hidden or 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> | |
void asalsayiya (int *aptr); | |
bool isprime (int *aptr); | |
void main() | |
{ | |
int a,*aptr; | |
printf("Bir sayi giriniz:"); | |
scanf_s("%d",&a); | |
aptr=&a; | |
asalsayiya(aptr); | |
printf("Sayidan buyuk en kucuk asal sayi:%d\n",*aptr); | |
} | |
void asalsayiya(int *aptr) | |
{ | |
while(1) | |
{ | |
++*aptr; | |
if(isprime(aptr)==true) | |
break; | |
} | |
} | |
bool isprime (int *aptr) | |
{ | |
int i; | |
for(i=2;i<*aptr;i++) | |
{ | |
if(*aptr%i==0) | |
return false; | |
} | |
return true; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment