r/ProgrammerHumor • • Jan 16 '14

[deleted by user]

[removed]

1.3k Upvotes

446 comments sorted by

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.

1

u/kqr Jan 17 '14

Actually there was a problem where someone wanted to know if all the numbers from 1 to some large number was Prime.

putStrLn (if largeNumber > 3 then "No" else "Yes")

...going by the literal interpretation again.

1

u/Kinglink Jan 17 '14

On the sheet it actually said the number I forget it ( I want to say 100,000) but that's a good answer.