C/C++ Arena

Step 7 of 7

Challenge: is it prime?

A prime is a whole number greater than 1 whose only divisors are 1 and itself.

Your turn: write int is_prime(int n) that returns 1 for primes and 0 otherwise. Only test divisors up to the square root (d * d <= n) so it stays fast for big numbers.

Previous: Recursion