Pergunta de entrevista da empresa FactSet

How work you work out all the prime numbers up to a given range?

Respostas da entrevista

Sigiloso

22 de abr. de 2012

Sieve of Eratosthenes algorithm. create an array of the numbers, set them all to the value 1. Start at 2, set every second number after 2 to 0. move to the next number (3). change every third number after three to zero. stop when there's no more numbers set to 1 or you reach the end of the array. At the end, the numbers marked 1 are the primes.

4

Sigiloso

28 de ago. de 2012

Interview candidate - did you give that answer in the interview? If so, what did they say?

Sigiloso

20 de abr. de 2012

Store all the prime numbers in an array and compare the next number with the array to find out whether it is prime or not.