Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function is_prime(n)
- if n < 2 then
- return false
- elseif n == 2 then
- return true
- elseif n % 2 == 0 then
- return false
- end
- result = true
- search_limit = math.ceil(math.sqrt(n))
- for i = 3, search_limit, 2 do
- if n % i == 0 then
- result = false
- break
- end
- end
- return result
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement