Primes Below a Given Number

Published by Mubashir Hassan in

Create a function that will find all primes below a given number. Return the result as an array.

Examples

primesBelowNum(5) ➞ [2, 3, 5]

primesBelowNum(10) ➞ [2, 3, 5, 7]

primesBelowNum(20) ➞ [2, 3, 5, 7, 11, 13, 17, 19]

Notes

If n is a prime, include it in the array.

Watch a quick demo on how Edabit works.