Primes up to N Problem

Primes up to N Problem — ExecCode Easy DSA Practice

Solve the Primes up to N problem on ExecCode. Free online easy DSA practice in Numbers & Math Logic. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Primes up to N. Your task is to compute the required answer and return space-separated primes. Integer n.

Examples

Input {"n": 10}; Output 2 3 5 7. Input {"n": 20}; Output 2 3 5 7 11 13 17 19. Input {"n": 100}; Output 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Constraints

1 <= n <= 10^6

Practice Primes up to N free on ExecCode. Browse DSA problems, topic map, and placement guides.