login
A075427
a(0) = 1; a(n) = a(n-1)+1 if n is even, otherwise a(n) = 2*a(n-1).
23
1, 2, 3, 6, 7, 14, 15, 30, 31, 62, 63, 126, 127, 254, 255, 510, 511, 1022, 1023, 2046, 2047, 4094, 4095, 8190, 8191, 16382, 16383, 32766, 32767, 65534, 65535, 131070, 131071, 262142, 262143, 524286, 524287, 1048574, 1048575, 2097150, 2097151, 4194302, 4194303, 8388606
OFFSET
0,2
COMMENTS
Fixed points for permutations A180200, A180201, A180198, and A180199. - Reinhard Zumkeller, Aug 15 2010
The Kn22 sums, see A180662, of triangle A194005 equal the terms of this sequence. - Johannes W. Meijer, Aug 16 2011
LINKS
Ralf Hinze, Concrete stream calculus: An extended study, J. Funct. Progr. 20 (5-6) (2010) 463-535, doi.
Yunhui Qi, Yuxuan Yang, and Yves Lepage, Towards number sequence completion through the analysis of number sequence patterns using numerical analogy, CEUR Proc. 4th Wksp. Interact. Analog. Reas. Mach. Learn., (IARML 2025) Int'l Joint Conf. Artif. Intel. (IJCAI 2025), hal-05315980, 14-25. See pp. 18-19.
FORMULA
a(0) = 1; for n >= 1, a(2*n) = 2^(n+1)-1, a(2*n-1) = 2^(n+1)-2; a(n) = 2^floor((n+3)/2) - 3/2 + (-1)^n/2. - Benoit Cloitre, Sep 17 2002 [corrected by Robert FERREOL, Jan 26 2011]
a(n) = (-1)^n/2 - 3/2 + 2^(n/2)*(1 + sqrt(2) + (1-sqrt(2))*(-1)^n). - Paul Barry, Apr 22 2004
From Paul Barry, Jul 30 2004: (Start)
Interleaved Mersenne numbers: interleaves 2*2^n-1 and 2(2*2^n-1) (A000225(n+1) and 2*A000225(n+1)).
G.f.: (1+2*x)/((1-x^2)*(1-2*x^2));
a(n) = 3*a(n-2) - 2*a(n-4);
a(n) = Sum_{k=0..n} binomial(floor((n+1)/2), floor((k+1)/2)). (End)
For n > 0: a(n) = (1 + n mod 2) * a(n-1) + 1 - (n mod 2). - Reinhard Zumkeller, Feb 27 2012
E.g.f.: 2*(cosh(sqrt(2)*x) - sinh(x) + sqrt(2)*sinh(sqrt(2)*x)) - cosh(x). - Stefano Spezia, Jul 11 2023
From Alois P. Heinz, Dec 27 2023: (Start)
a(n) = 2^floor((n+3)/2)-1-(n mod 2).
a(n) = A066880(n) for n>=1. (End)
MAPLE
A075427 := proc(n) if type(n, 'even') then 2^(n/2+1)-1 ; else 2^(1+(n+1)/2)-2 ; end if; end proc: seq(A075427(n), n=0..40); # R. J. Mathar, Feb 18 2011
isA := proc(n) convert(n, base, 2): 1 - %[1] = nops(%) - add(%) end:
select(isA, [$1..4095]); # Peter Luschny, Oct 27 2022
MATHEMATICA
a[0]=1; a[n_]:=a[n]=If[EvenQ[n], a[n-1]+1, 2*a[n-1]]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Mar 20 2011 *)
nxt[{n_, a_}]:={n+1, If[OddQ[n], a+1, 2a]}; Transpose[NestList[nxt, {0, 1}, 40]][[2]] (* or *) LinearRecurrence[{0, 3, 0, -2}, {1, 2, 3, 6}, 50] (* Harvey P. Dale, Mar 12 2016 *)
PROG
(Magma) [2^Floor((n+3)/2)-3/2+(-1)^n/2: n in [0..30]]; // Vincenzo Librandi, Aug 17 2011
(Haskell)
a075427 n = a075427_list !! n
a075427_list = 1 : f 1 1 where
f x y = z : f (x + 1) z where z = (1 + x `mod` 2) * y + 1 - x `mod` 2
-- Reinhard Zumkeller, Feb 27 2012
(PARI) a(n)=2^((n+3)\2)-3/2+(-1)^n/2 \\ Charles R Greathouse IV, Feb 06 2017
(Python)
def A075427(n): return (1<<(n>>1)+2)-2 if n&1 else (1<<(n>>1)+1)-1 # Chai Wah Wu, Apr 23 2023
CROSSREFS
Cf. A075426, A066880, A083416, A000225 (bisection), A000918 (bisection).
Sequence in context: A147303 A346593 A066880 * A075426 A359041 A191615
KEYWORD
nonn,nice,easy
AUTHOR
Reinhard Zumkeller, Sep 15 2002
EXTENSIONS
Formulae corrected and minor edits by Johannes W. Meijer, Aug 16 2011
STATUS
approved