Primes Under N - aloalgo

Primes Under N

Easy

You are given a positive integer n.

Your task is to return all prime numbers strictly less than n, in ascending order.

You may assume that:

  • n is in the range [1, 10000].
  • A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Return an empty list if there are no primes less than n.

Example 1

Input
10
Output
[2, 3, 5, 7]
Explanation:

The prime numbers less than 10 are 2, 3, 5, and 7.

Example 2

Input
2
Output
[]
Explanation:

There are no prime numbers less than 2.

Example 3

Input
20
Output
[2, 3, 5, 7, 11, 13, 17, 19]
Explanation:

The prime numbers less than 20 are 2, 3, 5, 7, 11, 13, 17, and 19.

Loading...
Input
10
Output
[2, 3, 5, 7]

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!