Prime Number Generator - aloalgo

Prime Number Generator

Medium

You are given an integer n.

Your task is to find and return a list of all prime numbers less than or equal to n.

Note that:

  • A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Return a list containing all prime numbers less than or equal to n.

Example 1

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

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

Example 2

Input
3
Output
[2, 3]
Explanation:

The prime numbers less than or equal to 3 are 2 and 3.

Example 3

Input
1
Output
[]
Explanation:

There are no prime numbers less than or equal to 1.

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!