Prime Numbers

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


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
  • Complete Solution
8849 successful submissions.
Click here to jump start your coding interview preparation