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”).

A348074
a(n) = A035327(n) if n is even, 3n + 1 if n is odd.
1
1, 4, 1, 10, 3, 16, 1, 22, 7, 28, 5, 34, 3, 40, 1, 46, 15, 52, 13, 58, 11, 64, 9, 70, 7, 76, 5, 82, 3, 88, 1, 94, 31, 100, 29, 106, 27, 112, 25, 118, 23, 124, 21, 130, 19, 136, 17, 142, 15, 148, 13, 154, 11, 160, 9, 166, 7, 172, 5, 178, 3, 184, 1, 190, 63
OFFSET
0,2
EXAMPLE
n parity function a(n)
= ===== ========= ======
0 even A035327(0) 1
1 odd 3*1 + 1 4
2 even A035327(2) 1
3 odd 3*3 + 1 10
4 even A035327(4) 3
5 odd 3*5 + 1 16
PROG
(Python)
def A348074(n):
if n%2==0:
if n==0: return 1
else: return (1<<int.bit_length(n)) - n - 1 #A035327(n)
else: return 3*n+1
(Python)
def A348074(n): return 3*n+1 if n&1 or n==0 else (~n)^(-1<<n.bit_length()) # Chai Wah Wu, Dec 20 2022
CROSSREFS
Sequence in context: A262370 A108759 A158824 * A334161 A039806 A030320
KEYWORD
nonn
AUTHOR
STATUS
approved