How Many "Prime Numbers" Are There?

Published by hiroimono in

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

Examples

primeNumbers(10) ➞ 4
// 2, 3, 5 and 7

primeNumbers(20) ➞ 8
// 2, 3, 5, 7, 11, 13, 17 and 19

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

Notes

N/A

Watch a quick demo on how Edabit works.