Home My space log
Language EN (English)

Find the prime numbers

Python Advanced astronaut ages teen+

The problem

Write a function primes_up_to(n). It gives back a list of every prime number from 2 up to n (n included), smallest first. A prime has no divisors except 1 and itself. Example: primes_up_to(10) gives [2, 3, 5, 7].

You will practice: loops inside loops, divisors, break, efficiency

Mode

Press Tab to indent. Press Esc and then Tab to move on to the next button.

Your code runs in your browser. We do not receive it or save it. Python is downloaded from cdn.jsdelivr.net the first time you run it (about 10 MB).

Test results

      What your code printed