how will u find Prime No below N<=10^6 within 2 sec whereas the Processor speed is low , Ram capacity is also limited..
sieve of Atkin
Cheacking each number wherther it is prime or not
Eratosthenes Sieve
none of the above