login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A330139
a(1)=1 and a(2)=1; if a(n-1) + a(n-2) == 0 (mod n) then a(n) = (a(n-1) + a(n-2))/n else a(n) = a(n-1) + a(n-2).
2
1, 1, 2, 3, 1, 4, 5, 9, 14, 23, 37, 5, 42, 47, 89, 136, 225, 361, 586, 947, 73, 1020, 1093, 2113, 3206, 5319, 8525, 13844, 22369, 36213, 58582, 94795, 153377, 248172, 401549, 649721, 1051270, 1700991, 2752261, 4453252, 7205513, 11658765, 18864278, 30523043, 49387321, 79910364, 129297685, 209208049, 338505734, 547713783
OFFSET
1,3
LINKS
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
Sequence in context: A338240 A265755 A341130 * A349358 A046671 A178760
KEYWORD
nonn,easy
AUTHOR
Eder Vanzei, Dec 02 2019
EXTENSIONS
Incorrect conjectured g.f. removed by Alois P. Heinz, Mar 28 2020
STATUS
approved