Re: interview question on primes




"Digital Puer" <digital_puer@xxxxxxxxxxx> wrote in message
news:94748b13-14f3-42ba-9ef8-1843d73f11e9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 25, 8:13 pm, "1787" <nob...@xxxxxxxx> wrote:
The useful answer then would
be to suggest algorithms that will actually find the primes for values of
A
and B appropriate to their absolute and relative magnitudes.


Can you explain this approach or give me a URL for
further reference?

--------------------------
I do agree with other replies that the interviewer should obviously
investigate the basic skill set of the programmer, which you demonstrated.
However, in all of my experience, the most successful cantidate has extended
the basic answer to approach the constraints and boundaries of a practical
application. In this case, the values of A and B are absolutely essential
components of actually finding the desired primes. Here, it is as important
to know that you can't currently factor a 1,000,000 digit number as it is to
know how to factor those that you can. The questions a cantidate poses can
be as insightful to an interviewer as the answers he or she provides.

The guidelines suggested in Peter Webb's response are good and of an
appropriate level for a response to an interview question. From his
posting:

The "correct" answer is heavily dependent on the range of values of A and
B,
and if this is all the question states, its a pretty poor question.

If A=1,000,000 and B=1,000,100 your approach is viable but probably
inefficient.

If A=7 and B=1,000,000 a sieve would be far more efficient.

If A= some 50 digit number and B=A+100, you would probably use a
pseudo-prime checking function with brute force used only for checking
possible pseudoprimes.



.



Relevant Pages

  • Re: My prime counting, understanding forms
    ... There are ways of making a probabilistic style proof absolute. ... And no help in proving things about primes. ... the original assumption regarding the probabilities of the event. ... (I use similar logic regarding primes, randomness and random ...
    (sci.math)
  • Re: Pi Reward?!
    ... whose numerator and denominator are both primes, ... absolute value of the product of the denominator and the error ...
    (sci.math)
  • Re: Polynomial primes!
    ... using absolute valuebut, how many primes can be ... added to this sequence and still maintain all 's ... /In God We Trust, Inc./. ...
    (sci.math)
  • Re: Polynomial primes!
    ... using absolute valuebut, how many primes can be ... added to this sequence and still maintain all 's ... I will just have to pickup from that point ...
    (sci.math)