Skip to main content
Practice

Coding Quiz - Find Prime Numbers

This coding quiz involves writing a function that returns a list of all prime numbers within a given integer range.

A prime number is a natural number greater than 1 that is not divisible by any numbers except 1 and itself.

Take a single integer n as input, and return a list that includes only the prime numbers from 2 to n.

For example, if n is 10, the function should return [2, 3, 5, 7].


Write the code
def solution(n):
# Write your code here
return



Constraints

  • The input n is an integer greater than or equal to 2.



Sample Input and Output

  • Input: 10

  • Output: [2, 3, 5, 7]


  • Input: 5

  • Output: [2, 3, 5]

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.