login
Least k such that 2^k begins with n but is not exactly n.
1

%I #25 Aug 06 2023 01:42:02

%S 4,8,5,12,9,6,46,13,53,10,50,7,17,47,77,14,34,54,84,11,31,51,61,81,8,

%T 18,38,48,68,78,98,15,25,35,45,55,75,85,95,12,22,32,42,145,52,62,72,

%U 82,92,102,9,19,29,39,142,49,59,162,69,79,89,192,99,109,16,119,26,36,139,46

%N Least k such that 2^k begins with n but is not exactly n.

%C This is not an injective function. a(2) = a(25) = 8.

%C a(n) > 3.

%e a(1) = 4 since 2^4 = 16 starts with 1 and is not 1 itself (the way 2^0 = 1 would be);

%e a(2) = 8 (not 1: 2^1 = 2) since 2^8 = 256;

%e a(3) = 5 since 2^5 = 32;

%e a(4) = 12 (not 2: 2^2 = 4) since 2^12 = 4096;

%e a(5) = 9 since 2^9 = 512; etc.

%t a[n_] := Block[{j = IntegerLength@ n, k = 1}, While[ IntegerLength[2^k] < j || Quotient[2^k, 10^(IntegerLength[2^k] - j)] != n || n == 2^k, k++]; k]; Array[ a, 70]

%o (Python)

%o def A363873(n):

%o m, s = 1<<(k:=n.bit_length()-1), str(n)

%o while m<=n or not str(m).startswith(s):

%o k += 1

%o m <<= 1

%o return k # _Chai Wah Wu_, Aug 06 2023

%Y Cf. A000079, A018856.

%K nonn,base

%O 1,1

%A _Robert G. Wilson v_, Jul 03 2023