Prime Numbers

Given a number N, find all prime numbers upto N ( N included ).

Example:

if N = 7,

all primes till 7 = {2, 3, 5, 7}

Make sure the returned array is sorted.

Problem Approach:

Complete code in the hint.

Interview Code Editor
Hints
  • Complete Solution
6529 successful submissions.
Click here to jump start your coding interview preparation