Skip to content

Instantly share code, notes, and snippets.

@megascus
Created August 12, 2012 11:30
Show Gist options
  • Save megascus/3331480 to your computer and use it in GitHub Desktop.
Save megascus/3331480 to your computer and use it in GitHub Desktop.
素数の時にJoJo2(Java)
/**
*
* @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