OFFSET
0,2
COMMENTS
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..16384
Michael De Vlieger, Plot binary expansion of a(n) arranged with smallest bit at bottom and largest at top, n increasing from left to right for n = 0..3071. Black indicates 1, white indicates 0.
EXAMPLE
For n=1, 3*n+1 = 4, "100" in binary, when we substitute 01's for the two trailing 0's, we obtain 21, "10101" in binary, therefore a(1) = 21.
For n=6, 3*6+1 = 19, "10011" in binary, and there are no trailing 0's, and no changes, therefore a(6) = 19.
For n=7, 3*7+1 = 22, "10110" in binary, with one trailing 0, which when replaced with 01 gives us 45, "101101" in binary, therefore a(7) = 45.
For n=229, there are e=4 trailing bit expansions 0 -> 01,
3n+1 = binary 101011 0 0 0 0
a(n) = binary 101011 01010101
MATHEMATICA
Array[#2*(2^#3) + ((4^#3) - 1)/3 & @@ {#1, #2, IntegerExponent[#2, 2]} & @@ {#, 3 #1 + 1} &, 67, 0] (* Michael De Vlieger, Apr 19 2024 *)
PROG
(PARI) A371094(n) = { my(m=1+3*n, e=valuation(m, 2)); ((m*(2^e)) + (((4^e)-1)/3)); };
(Python)
def A371094(n): return ((m:=3*n+1)<<(e:=(~m & m-1).bit_length()))+((1<<(e<<1))-1)//3 # Chai Wah Wu, Apr 28 2024
CROSSREFS
Cf. also A302338.
KEYWORD
nonn,easy
AUTHOR
Antti Karttunen (proposed by Ali Sada), Apr 19 2024
STATUS
approved