Skip to main content

Number is Prime

Problem Description​

Write a function that accepts an integer as its parameter and returns true if the number is prime.

Tip: A number is considered prime if it is greater than one and has no positive divisors other than 1 and itself.

Input​

  • A single integer.

Output​

  • A boolean value: true if the number is prime, false otherwise.

Constraints​

  • The input number can be any integer.

Example​

Input:
11

Output:
true

Explanation:
The number 11 is prime because it has no divisors other than 1 and itself.

Input:
13

Output:
true

Explanation:
The number 13 is prime because it has no divisors other than 1 and itself.

Input:
4

Output:
false

Explanation:
The number 4 is not prime because it is divisible by 2.

Input:
9

Output:
false

Explanation:
The number 9 is not prime because it is divisible by 3.

Input:
16777259

Output:
true

Explanation:
The number 16777259 is prime because it has no divisors other than 1 and itself.