Flag the Indivisible Token

Intermediate

A sharding scheme prefers bucket counts that have no smaller divisors, so the configuration validator needs to know whether a candidate number is prime.

Implement `solve(Integer n)` to return true if `n` is a prime number (greater than 1 with no divisors other than 1 and itself), false otherwise.

Examples

Inputn = 7
Outputtrue
Inputn = 9
Outputfalse
Hints
  • Numbers below 2 are not prime.
  • Only test divisors up to the square root of n.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.