← Back to challenges

How Many "Prime Numbers" Are There?

PythonHardalgebraalgorithmsconditionsmathloops

Instructions

Create a function that finds how many prime numbers there are, up to the given integer.

Examples

prime_numbers(10) ➞ 4
# 2, 3, 5 and 7

prime_numbers(20) ➞ 8
# 2, 3, 5, 7, 11, 13, 17 and 19

prime_numbers(30) ➞ 10
# 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.