Skip to content

Instantly share code, notes, and snippets.

@ahmetilhann
Last active December 30, 2015 07:09
Show Gist options
  • Save ahmetilhann/7794496 to your computer and use it in GitHub Desktop.
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
#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