A company raffle page only hands out ticket numbers that are prime. Tickets are numbered from 1 to n.
Write primeTickets(n) that returns every prime number from 2 to n, in ascending order. Return [] if there are none.
Input: n = 10 Output: [2,3,5,7]
The primes up to 10. 9 = 3 × 3 and the even numbers above 2 are crossed out.
Input: n = 1 Output: []
1 is not prime, so there are no tickets.
0 <= n <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #637 Prime Raffle Tickets. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.