[go: up one dir, main page]

login
A245471
If n is odd, then a(n) = A065621(n+1). If n is even, then a(n) = n/2.
5
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, 14, 38, 15, 32, 16, 98, 17, 100, 18, 110, 19, 104, 20, 122, 21, 124, 22, 118, 23, 112, 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
OFFSET
1,1
COMMENTS
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).
LINKS
PROG
(Haskell)
import Data.List (transpose)
a245471 n = a245471_list !! (n-1)
a245471_list = concat $ transpose [odds a065621_list, [1..]]
where odds [] = []; odds [x] = []; odds (_:x:xs) = x : odds xs
-- Reinhard Zumkeller, Jul 27 2014
(Python)
def A245471(n): return (m:=n+1)^ (m&~-m)<<1 if n&1 else n>>1 # Chai Wah Wu, Jun 29 2022
CROSSREFS
Sequence in context: A059970 A326889 A309303 * A352548 A258090 A112157
KEYWORD
nonn,base,look
AUTHOR
Reinhard Muehlfeld, Jul 23 2014
EXTENSIONS
Definition corrected by Chai Wah Wu, Jun 29 2022
STATUS
approved