login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A265496 Numbers n resulting from alternately applying the operations +, -, *, / to the last term and second to last term. 0
1, 2, 3, 1, 3, 3, 6, 3, 18, 6, 24, 18, 432, 24, 456, 432, 196992, 456, 197448, 196992, 38895676416, 197448, 38895873864, 38895676416, 1512881323731695591424, 38895873864, 1512881323770591465288, 1512881323731695591424, 2288809899755012359448064967916189926490112 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
LINKS
FORMULA
a(n) = n+1 for n in {0, 1}, otherwise
a(n+1) = a(n) + a(n-1) if n mod 4 = 1,
a(n+1) = a(n) - a(n-1) if n mod 4 = 2,
a(n+1) = a(n) * a(n-1) if n mod 4 = 3,
a(n+1) = a(n) / a(n-1) if n mod 4 = 0.
From Robert Israel, Dec 22 2015: (Start)
a(4n+8) = a(4n+4)^2*(1+1/a(4n)).
a(4n+9) = a(4n+5)*(a(4n+5)+a(4n+1)+1).
a(4n+10) = a(4n+6)*(a(4n+6)-a(4n+2)+1).
a(4n+11) = a(4n+7)^2*(1+1/a(4n+3)). (End)
EXAMPLE
a(0) = 1.
a(1) = 2.
a(2) = a(1) + a(0) = 2 + 1 = 3.
a(3) = a(2) - a(1) = 3 - 2 = 1.
a(4) = a(3) * a(2) = 1 * 3 = 3.
a(5) = a(4) / a(3) = 3 / 1 = 3.
a(6) = a(5) + a(4) = 3 + 3 = 6.
a(7) = a(6) - a(5) = 6 - 3 = 3.
a(8) = a(7) * a(6) = 3 * 6 = 18.
a(9) = a(8) / a(7) = 18 / 3 = 6.
MAPLE
f:= proc(n) option remember;
if n mod 4 = 2 then procname(n-1)+procname(n-2)
elif n mod 4 = 3 then procname(n-1)-procname(n-2)
elif n mod 4 = 0 then procname(n-1)*procname(n-2)
else procname(n-3)
fi
end proc:
f(0):= 1: f(1):= 2:
seq(f(i), i=0..20); # Robert Israel, Dec 22 2015
MATHEMATICA
a[0] = 1; a[1] = 2; a[x_] := a[x] = Which[Mod[x, 4] == 2, a[x - 1] + a[x - 2], Mod[x, 4] == 3, a[x - 1] - a[x - 2], Mod[x, 4] == 0, a[x - 1] a[x - 2], Mod[x, 4] == 1, a[x - 1]/a[x - 2]]; Table[a@ n, {n, 0, 30}] (* Michael De Vlieger, Dec 22 2015 *)
PROG
(BASIC)
input a(0)
input a(1)
for n=1 to 1000
begin
if n mod 4 =1 then a(n+1):=a(n)+a(n-1)
if n mod 4 =2 then a(n+1):=a(n)-a(n-1)
if n mod 4 =3 then a(n+1):=a(n)*a(n-1)
if n mod 4 =0 then a(n+1):=a(n)/a(n-1)
print a(n+1)
end
(PARI) lista(nn) = {print1(x = 1, ", "); print1(y = 2, ", "); for (n=1, nn, if (n % 4 == 1, z = x+y); if (n % 4 == 2, z = y-x); if (n % 4 == 3, z = x*y); if (n % 4 == 0, z = y/x); print1(z, ", "); x = y; y = z; ); } \\ Michel Marcus, Dec 22 2015
CROSSREFS
Cf. A131183.
Sequence in context: A338988 A046821 A239691 * A238793 A240677 A030306
KEYWORD
nonn,easy
AUTHOR
Florent Martigne, Dec 09 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)