Yeah this question is bogus

Tags: #<Tag:0x00007f2428cf33e0>


You can’t get to 0 by taking a positive number and dividing by two. The number will get smaller and smaller and never reach 0. The best you can hope for is to divide until you have a number smaller than your floating point library can handle which still may or may not get to 0. The answer is definitely NOT O(log n)

What a crap question, can you get rid of it please?


OK yes I see it is declared as “int” but please keep in mind that some programming languages like Perl have a single “scalar number” type and will switch to floating point automatically. Solutions that depend on a specific language or a specific math library are crap. You could just change it to i < 1 and save everyone some heartburn.