A135287 a(0)=1; for n > 0, a(n) = a(n-1)+n if a(n-1) is odd, else a(n) = a(n-1)/2.
1, 2, 1, 4, 2, 1, 7, 14, 7, 16, 8, 4, 2, 1, 15, 30, 15, 32, 16, 8, 4, 2, 1, 24, 12, 6, 3, 30, 15, 44, 22, 11, 43, 76, 38, 19, 55, 92, 46, 23, 63, 104, 52, 26, 13, 58, 29, 76, 38, 19, 69, 120, 60, 30, 15, 70, 35, 92, 46, 23, 83
Offset: 0
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Programs
-
Haskell
a135287 n = a135287_list !! n a135287_list = 1 : f 1 1 where f x y = z : f (x + 1) z where z = if m == 0 then y' else x + y; (y',m) = divMod y 2 -- Reinhard Zumkeller, Mar 02 2012
-
Maple
A135287 := proc(n) option remember ; if n = 0 then 1 ; elif A135287(n-1) mod 2 = 0 then A135287(n-1)/2 ; else n+A135287(n-1) ; fi ; end: seq(A135287(n),n=0..60) ; # R. J. Mathar, Dec 12 2007
-
Mathematica
nxt[{n_,a_}]:={n+1,If[OddQ[a],a+n+1,a/2]}; NestList[nxt,{0,1},60][[;;,2]] (* Harvey P. Dale, Mar 02 2023 *)
Extensions
More terms from R. J. Mathar, Dec 12 2007
Offset fixed by Reinhard Zumkeller, Mar 02 2012
Comments