Searching in sqrt(n) |
In binary, the square root of 2, denoted by sqrt(2), is an infinite number 1.0110101000001001111...
Given an integer n and a binary string (i.e. a string consisting of 0 and 1) S, your task is to find the first occurrence of S in the fraction part (i.e. the part after the decimal point) of sqrt(n). In case sqrt(n) is an integer, the fraction part is an infinite sequence of zeros.
2 2 101 1202 110011
2 58