You are viewing a single comment's thread. Return to all comments →
My solution Java 7 (I haven't read the editorial yet)
public static String primality(int n) { if (n < 2) { return "Not prime"; } for (int i = 2 ; i < n ; i++) { if (n % i == 0) { return "Not prime"; } } return "Prime"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Complexity: Primality
You are viewing a single comment's thread. Return to all comments →
My solution Java 7 (I haven't read the editorial yet)