Created
April 22, 2014 02:53
-
-
Save ktnyt/11163902 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> | |
int isPrime(int n) { | |
int i; | |
for(i = 2; i * i <= n; ++i) { | |
if(n % i == 0) { | |
return 0; | |
} | |
} | |
return 1; | |
} | |
int main() { | |
int i, j, f; | |
for(i = 2; i < 100; ++i) { | |
if(isPrime(i)) { | |
printf("%d\n", i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment