By mitchp
via java.dzone.com
Published: Dec 13 2012 / 08:51
Write a function that calculates the integer square root of any positive integer, but only uses add, subtract, left and right shifts, but no division or multiplication. The algorithm must run in O(log n) time. By integer square root I mean the largest integer whose square is less than or equal to a given number.
Add your comment