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”).
%I #22 Nov 23 2022 10:08:27
%S 5,4,5,6,8,8,11,10,14,12,17,14,20,16,23,18,26,20,29,22,32,24,35,26,38,
%T 28,41,30,44,32,47,34,50,36,53,38,56,40,59,42,62,44,65,46,68,48,71,50,
%U 74,52,77,54,80,56,83,58,86,60,89,62,92,64,95,66,98,68,101,70,104,72
%N Let u(n,k) be the recursion defined by u(n,1)=1, u(n,2)=2, u(n,3)=n, and u(n,k+3) = (u(n,k+2) + u(n,k+1))/u(n,k) if u(n,k) divides u(n,k+2) + u(n,k+1), u(n,k+3) = u(n,k) otherwise. Then u(n,k) is periodic and a(n) = Max(u(n,k), k >= 1).
%C Let p(n) denote the period of u(n,k) (i.e., p(n) is the smallest integer such that u(n,k) = u(n, k+p(n))). p(n) = 22,12,22,21,15,9,15,9,15,9,... for n = 1,2,3,4,5,6,.... Hence for n > 4, p(n) = 15 if n is odd; p(n) = 9 if n is even.
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (0,2,0,-1).
%F a(1)=5, a(2n)=2n+2, a(2n+1)=3n+2.
%F a(n) = (5*n+5-(n-3)*(-1)^n)/4 for n>=2, with a(1)=5. - _Wesley Ivan Hurt_, Sep 05 2022
%e E.g., for k=1..15, u(7, k) = 1, 2, 7, 9, 8, 7, 9, 2, 7, 1, 4, 7, 11, 4, 7; hence a(7)=11.
%t LinearRecurrence[{0, 2, 0, -1}, {5, 4, 5, 6}, 70] (* _Georg Fischer_, Nov 23 2022 *)
%o (Perl)
%o use strict; use integer;
%o for (my $n = 1; $n <= 70; $n ++) { my @u = (0, 1, 2, $n);
%o for (my $k = 1; $k <= 64; $k ++) {
%o my $sum = $u[$k + 1] + $u[$k + 2];
%o $u[$k + 3] = ($sum % $u[$k] == 0) ? $sum / $u[$k] : $u[$k];
%o }
%o my $max = 0;
%o for (my $k = 1; $k < scalar(@u); $k ++) {
%o if ($max < $u[$k]) { $max = $u[$k]; }
%o }
%o print "$n $max\n";
%o } # _Georg Fischer_, Nov 23 2022
%K nonn
%O 1,1
%A _Benoit Cloitre_, Apr 11 2002
%E a(65), a(67), a(69) corrected by _Georg Fischer_, Nov 23 2022