Created
August 12, 2012 11:30
-
-
Save megascus/3331480 to your computer and use it in GitHub Desktop.
素数の時にJoJo2(Java)
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
/** | |
* | |
* @author megascus | |
*/ | |
public class JoJo { | |
public static void main(String[] args) { | |
for (int i = 1; i <= 100; i++) System.out.println(isPrime(i) ? "JoJo" : i); | |
} | |
static boolean isPrime(int p) { | |
if (p < 2) return false; | |
for (int i = 2; i < p; i++) if (p % i == 0) return false; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment