Find Prime Numbers

Advanced

Introduction

Hey there, young coder! Today, we're going to uncover the magical world of prime numbers. Your quest is to create a function that finds all the prime numbers up to a certain number. Remember, a prime number is a special kind of number that can only be divided evenly by 1 and itself. Are you ready to find these mysterious numbers?

Task

Your task is to write a function find_primes_up_to that takes one input—a positive integer—and returns a list of all the prime numbers less than or equal to that number.

For example, if the number is 10, the prime numbers less than or equal to 10 are 2, 3, 5, and 7.

Here's how your function should work:

find_primes_up_to(10) # Returns [2, 3, 5, 7] find_primes_up_to(5) # Returns [2, 3, 5] find_primes_up_to(2) # Returns [2] because 2 is the first prime number! find_primes_up_to(1) # Returns [] since there's no prime number less than or equal to 1.

Let's Code!

  • Implement the function find_primes_up_to.
  • Remember, your function should return a list.

Good luck, and may the prime numbers be ever in your favor!

Geek
Inputs

Arg 1:

10
Expected Output
[2, 3, 5, 7]
Actual Output