[go: up one dir, main page]

login
If n is odd, then a(n) = A065621(n+1). If n is even, then a(n) = n/2.
5

%I #21 Jul 01 2022 09:39:44

%S 2,1,4,2,14,3,8,4,26,5,28,6,22,7,16,8,50,9,52,10,62,11,56,12,42,13,44,

%T 14,38,15,32,16,98,17,100,18,110,19,104,20,122,21,124,22,118,23,112,

%U 24,82,25,84,26,94,27,88,28,74,29,76,30,70,31,64,32,194,33,196,34,206,35,200,36,218,37,220,38,214,39,208,40,242,41,244,42,254,43,248,44,234,45,236,46,230,47,224,48,162,49,164,50,174,51,168,52,186,53,188,54,182,55,176,56,146,57,148,58,158,59,152,60

%N If n is odd, then a(n) = A065621(n+1). If n is even, then a(n) = n/2.

%C A Collatz-like function: the difference is that for odd n the term 3n+1 is calculated without overflow, only using xor operations (n xor(2n+1)). It is known that for each argument the iterated function always ends up in a cycle which contains 1 (namely 1-2-1).

%H Reinhard Zumkeller, <a href="/A245471/b245471.txt">Table of n, a(n) for n = 1..8192</a>

%o (Haskell)

%o import Data.List (transpose)

%o a245471 n = a245471_list !! (n-1)

%o a245471_list = concat $ transpose [odds a065621_list, [1..]]

%o where odds [] = []; odds [x] = []; odds (_:x:xs) = x : odds xs

%o -- _Reinhard Zumkeller_, Jul 27 2014

%o (Python)

%o def A245471(n): return (m:=n+1)^ (m&~-m)<<1 if n&1 else n>>1 # _Chai Wah Wu_, Jun 29 2022

%Y Cf. A006370, A065621.

%K nonn,base,look

%O 1,1

%A _Reinhard Muehlfeld_, Jul 23 2014

%E Definition corrected by _Chai Wah Wu_, Jun 29 2022