by davidcuddeback · 14y ago · 0 comments
A solution to this is looking at the distance from the current sum to the "boundary":
abs(round(sum, 5) - sum) > next_term
which works because this is an alternating series.I guess that demonstrates why it's important to have a REPL or a compiler available for the interviewee. (My computer wasn't available at the time that I wrote the comment.) I just wrote up my solution and confirmed that its terminating condition isn't correct.
There's a mindboggling amount of people applying for programming jobs who can't even do that!