Primes are numbers which are only divisible by 1 and themselves.

5 is a prime since it can only be divided by itself and 1. 9 is not a prime since it can be divided by 3 (3*3 = 9). 1 is not a prime for reasons that only mathematicians care about.

To check if a number is prime, we can implement a basic algorithm, namely: check if a given number can be divided by any numbers smaller than the given number (note: you really only need to test numbers up to the square root of a given number, but it doesn't really matter for this assignment).

```
In [98]:
```def list_primes(n):
primes = []
for p in range(2, n + 1): # we add a '+ 1' to be inclusive.
for num in range(2, p):
if p % num == 0:
break
else:
primes.append(p)
return primes

```
In [100]:
```

```
```

```
In [101]:
```%run -i test_list_primes.py

```
```

```
In [ ]:
```

```
In [ ]:
```