OFFSET
1,1
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..11
A. Knopfmacher and J. Knopfmacher, An alternating product representation for real numbers, in Applications of Fibonacci numbers, Vol. 3 (Kluwer 1990), pp. 209-216.
MAPLE
a:= proc(n) option remember;
if n=1 then 2
elif `mod`(n, 2) = 0 then 2*(a(n-1) +1)^2 -1
else 2*(a(n-1)^2 -1)
end if; end proc;
seq(a(n), n = 1..9); # G. C. Greubel, Mar 04 2020
MATHEMATICA
a[n_]:= a[n]= If[n==1, 2, If[EvenQ[n], 2*(a[n-1] +1)^2 -1, 2*a[n-1]^2 -2]]; Table[a[n], {n, 9}] (* G. C. Greubel, Mar 04 2020 *)
PROG
(PARI) a(n) = if (n==1, 2, if (n % 2, 2*a(n-1)^2 - 2, 2*(a(n-1)+1)^2 - 1)); \\ Michel Marcus, Feb 20 2019
(Magma)
function a(n)
if n eq 1 then return 2;
elif n mod 2 eq 0 then return 2*(a(n-1) +1)^2 -1;
else return 2*(a(n-1)^2 -1);
end if; return a; end function;
[a(n): n in [1..9]]; // G. C. Greubel, Mar 04 2020
(Sage)
@CachedFunction
def a(n):
if (n==1): return 2
elif (n%2==0): return 2*(a(n-1) +1)^2 -1
else: return 2*(a(n-1)^2 -1)
[a(n) for n in (1..9)] # G. C. Greubel, Mar 04 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
More terms from Christian G. Bower, Jan 06 2006
STATUS
approved