TRG Interview Question
Software Engineer / DevelopersAssuming that you want a prime number in a given range. It is a known theorem that there are n/log(n) prime numbers till N.
So, given a and b, find the number of prime numbers(say p) from 1 to b, and also find the number of primes(say q) from 1 to a.
So, there are q-p prime numbers between a and b. So, for every (b-a)/(q-p), there should be a prime number, so try all numbers from a till a+( (b-a)/(q-p) ) and you should find one.
(unique?? random?? )prime numbers. never heard of such prime numbers
- GekkoGordan February 07, 2011