



Explanation:

k = 2; As long as (k < n) do { 1. Divide n by k 2. If n is divisible by k, then return NO 3. Otherwise, increase k by 1 } return YES 
public static boolean isPrime( int n ) { int k = 2; while ( k++ < n ) { if ( n%k == 0) return false; } return true; } 





Explanation:






