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
Vincenzo Librandi, Table of n, a(n) for n = 0..2000
R. Hinze, Concrete stream calculus: An extended study, J. Funct. Progr. 20 (5-6) (2010) 463-535, doi.
Index entries for linear recurrences with constant coefficients, signature (0,3,0,-2).
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)
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
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