This is clever. Actually there was a problem where someone wanted to know if all the numbers from 1 to some large number was Prime. the large number was under 100,000
So I wrote the program, and then left a second answer. I used the first program to generate the answers into a file, used that output as a array, (depending the number they pushed, I would output X of the array up to that number) and just posted that as my answer. Explaining the answer (Just looking up the first 100,000 values is faster than the sieve of eratosthenes.)
The question emphasized speed over algorithm, but I forgot what happened with the interview so I have no idea if that was the better answer.
View all comments
1
u/Kinglink Jan 16 '14
This is clever. Actually there was a problem where someone wanted to know if all the numbers from 1 to some large number was Prime. the large number was under 100,000
So I wrote the program, and then left a second answer. I used the first program to generate the answers into a file, used that output as a array, (depending the number they pushed, I would output X of the array up to that number) and just posted that as my answer. Explaining the answer (Just looking up the first 100,000 values is faster than the sieve of eratosthenes.)
The question emphasized speed over algorithm, but I forgot what happened with the interview so I have no idea if that was the better answer.