O (log (n)). , abs(n - 1)
- 2, i /= 2
, i
( ) , abs(i / 2)
, - .
n - 1
2, n - 1 == 2**a
a
, a + 1
( i
, 1 = 2**0
, 2 = 2**1
, 4 = 2**2
,..., n - 1 = 2**a
). lg (n - 1) + 1 .
, , , , , . , () O (log (n)), , " n" /log (n), n , . , , ? log (n) , . (2, 10 e, ) lg (n - 1) lg ( n - 1 + (-) m) + (-) p m p.