login
Let f(p, q) denote the pair (p + q, wt(p) + wt(q)). a(n) gives the number of iterations of f starting at (n, 1) needed to make p/q an integer, or if no integer is ever reached then a(n) = -1. (Here wt is binary weight, A000120.)
3

%I #22 Feb 02 2019 19:59:32

%S 1,3,3,3,1,2,1,11,4,10,1,3,4,9,2,19,1,18,1,1,7,17,7,7,6,5,6,6,1,4,15,

%T 5,16,4,1,2,4,3,1,14,3,13,13,13,12,12,1,6,12,2,5,5,11,1,5,13,10,4,1,

%U 12,3,9,3,3,1,2,1,1,40,2,8,8,39,3,7,7,9,2,3,1,3,37,37,37,5,36,36,3,1,8

%N Let f(p, q) denote the pair (p + q, wt(p) + wt(q)). a(n) gives the number of iterations of f starting at (n, 1) needed to make p/q an integer, or if no integer is ever reached then a(n) = -1. (Here wt is binary weight, A000120.)

%e n=8; (8, 1) -> (9, 2) -> (11, 3) -> (14, 5) -> (19, 5) -> (24, 5) -> (29, 4) -> (33, 5) -> (38, 4) -> (42, 4) -> 46, 4) -> (50, 5). 50/5 = 10, so a(8) = 11 because it needs 11 iterations until p/q is an integer.

%o (PARI) f(v) = return([v[1]+v[2], hammingweight(v[1])+hammingweight(v[2])]);

%o a(n) = {my(nb = 0, v = [n, 1]); while (1, v = f(v); nb++; if (frac(v[1]/v[2]) == 0, return (nb)));} \\ _Michel Marcus_, Jan 13 2019

%Y Cf. A323275, A000120.

%K nonn,base

%O 1,2

%A _Ctibor O. Zizka_, Jan 12 2019