Exercise

# Prime number sequence

A prime number is a positive number that is divisible only by 1 or itself (*e.g.* 3, 7, 11 *etc.*). However, 1 is not a prime number.

Your task is, given a list of candidate numbers `cands`

, to filter only prime numbers in a new list `primes`

.

But first, you need to create a function `is_prime()`

that returns `True`

if the input number \(n\) is prime or `False`

, otherwise. A number is prime if it is not divisible by any integer number from 2 to \(\sqrt{n}\) (any number \(n\) is not divisible by anything higher than \(\sqrt{n}\)).

Tip: you might need to use the `%`

operator that calculates a remainder from a division (*e.g.* `8 % 3`

is `2`

).

The `math`

module is already imported.

Instructions 1/2

**undefined XP**

- Define the initial check: numbers lower than 2 are not prime.
- Define the loop checking if the number
`n`

is not prime.