Prime numbers

Report a typo

In math, we call a natural number prime if it's greater than 1 and can be divided without any remainder only by 1 and itself:

2, 3, 5, 7, 11, 13, 17, ...

Create a list of all prime numbers up to 1000 in the code below. Just save this list into a variable prime_numbers, you don't have to print anything.

Make use of any() or all() to check if a number n leaves a zero remainder when divided by values from 2 to n - 1 (inclusively).

Write a program in Python 3
prime_numbers = ...
___

Create a free account to access the full topic