Last active
May 20, 2019 10:48
-
-
Save LightBells/8658e31629e8f8d9fa940eb41336c391 to your computer and use it in GitHub Desktop.
PrimeJudgement
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> | |
#define FALSE 0 | |
#define TRUE 1 | |
int main(){ | |
bool isNotPrime = FALSE; | |
for (int i=2 ; i <= 1000 ; i++) { | |
for (int j=2 ; j < i ; j++){ | |
if ( i%j == 0 ){ | |
isNotPrime = TRUE; | |
} | |
} | |
if (isNotPrime == FALSE){ | |
printf("%4d\n", i); | |
} | |
isNotPrime = FALSE; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
判定用変数はisNotPrime
ある数n∈Nが任意のx {x | x∈N, 1<x<n}で割ることができない数であることが素数の条件だから、それをチェックしてる。