Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kokubo-haruya
Last active January 11, 2019 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokubo-haruya/4d63e3c51c181d26439ffde114fc2dd1 to your computer and use it in GitHub Desktop.
Save kokubo-haruya/4d63e3c51c181d26439ffde114fc2dd1 to your computer and use it in GitHub Desktop.
Programming Basic No.10
#include<stdio.h>
int main()
{
int N,cnt,point,max,check;
printf("Pls enter the [MAX] number you want to judge the one which is a prime number\n");
printf("->");
scanf("%d",&max);
printf("2 is a prime number \n");
for(N=3;N<=max;N++)
{
point=0;
for(cnt=2;cnt<N-1;cnt++)
{
check=N%cnt;
if(check==0)
{
point++;
}
}
if(point==0)
{
printf("%d is a prime number \n",N);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment