Testing for Primes · Compiler
Testing for Primes
Test n for primality. If n has a divisor strictly between 1 and n, find the smallest such divisor. Handle 1 separately.
- Input
- One integer n from 1 to 1000000.
- Output
- Print the smallest divisor strictly between 1 and n if one exists. Print PRIME if n is prime, or NEITHER if n is 1.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…