You are viewing a single comment's thread. Return to all comments →
ruby def is_prime(n) return false if n <= 1 return true if n <= 3 return false if ((n % 2) == 0) || ((n % 3) == 0) i = 5 # check division on 6k+i polinom # cause all primes are of the form 6k ± 1, with the exception of 2 and 3. while i*i <= n return false if n % i == 0 || n % (i + 2) == 0 i += 6 end return true end
Seems like cookies are disabled on this browser, please enable them to open this website
Day 25: Running Time and Complexity
You are viewing a single comment's thread. Return to all comments →