A274593 a(0) = 0; thereafter, a(2*n+1) = a(n)+2*n+1, otherwise a(n) = n.
0, 1, 2, 4, 4, 7, 6, 11, 8, 13, 10, 18, 12, 19, 14, 26, 16, 25, 18, 32, 20, 31, 22, 41, 24, 37, 26, 46, 28, 43, 30, 57, 32, 49, 34, 60, 36, 55, 38, 71, 40, 61, 42, 74, 44, 67, 46, 88, 48, 73, 50, 88, 52, 79, 54, 101, 56, 85, 58, 102
Offset: 0
Examples
11 = 2^0*(11+1)-1 = 2^1*(5+1)-1 = 2^2*(2+1)-1, so a(11) = 11+5+2 = 18.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Programs
-
Maple
f:= proc(n) option remember; if n::even then n else n + procname((n-1)/2) fi end proc: map(f, [$0..100]); # Robert Israel, Jul 04 2016
-
Mathematica
a[0] = 0; a[n_] := a[n] = If[OddQ@ n, a[#] + 2 # + 1 &[(n - 1)/2], n]; Table[a@ n, {n, 0, 59}] (* Michael De Vlieger, Jul 04 2016 *)
-
Python
def A274593(n): return (((m:=~(n+1)&n)<<1)+1)*((n>>(k:=m.bit_length()))|1)-k-1 # Chai Wah Wu, Jul 13 2022
Comments