OFFSET
1,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..4800
FORMULA
If a(n-1) + a(n-2) == 0 (mod n) then a(n) = (a(n-1) + a(n-2))/n, otherwise a(n) = a(n-1) + a(n-2).
a(n) != a(n-1) + a(n-2) for n in A333578.
EXAMPLE
a(5) = 1 because a(4) + a(3) = 5, and 5 mod 5 = 0, so a(5) = (a(4) + a(3))/5 = 1.
MAPLE
a:= proc(n) option remember; `if`(n<2, n, (t->
`if`(irem(t, n)=0, t/n, t))(a(n-1)+a(n-2)))
end:
seq(a(n), n=1..50); # Alois P. Heinz, Mar 28 2020
MATHEMATICA
a[1] = a[2] = 1; a[n_] := a[n] = If[Divisible[(s = a[n-1] + a[n-2]), n], s/n, s]; Array[a, 50] (* Amiram Eldar, Dec 02 2019 *)
nxt[{n_, a_, b_}]:={n+1, b, Which[Divisible[a+b, n+1], (a+b)/(n+1), True, a+b]}; NestList[nxt, {2, 1, 1}, 50][[All, 2]] (* Harvey P. Dale, May 22 2021 *)
PROG
(Pascal)
Begin
.....n1[1]:=1;
.....n1[2]:=1;
.....writeln(n1[1], ', ');
.....writeln(n1[2], ', ');
.....for n2:=3 to 100 do
.....begin
........n1[n2] := n1[n2-1]+n1[n2-2];
........if n1[n2]mod(n2) = 0 then
........begin
...........n1[n2] := int(n1[n2]/n2);
........end;
........writeln(n1[n2], ', ');
.....end;
End.
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Eder Vanzei, Dec 02 2019
EXTENSIONS
Incorrect conjectured g.f. removed by Alois P. Heinz, Mar 28 2020
STATUS
approved