login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A323375
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
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, 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, 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
OFFSET
1,2
EXAMPLE
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.
PROG
(PARI) f(v) = return([v[1]+v[2], hammingweight(v[1])+hammingweight(v[2])]);
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
CROSSREFS
Sequence in context: A119560 A172364 A323596 * A140366 A167817 A153401
KEYWORD
nonn,base
AUTHOR
Ctibor O. Zizka, Jan 12 2019
STATUS
approved