login
a(1)=1, a(2)=1. a(n) = the sum of the two largest earlier terms which are both coprime to n.
2

%I #16 Nov 01 2019 12:46:37

%S 1,1,2,2,4,2,6,2,6,2,12,2,18,2,6,2,30,2,48,2,6,2,78,2,126,2,6,2,204,2,

%T 330,2,6,2,282,2,612,2,6,2,942,2,1554,2,6,2,2496,2,3438,2,6,2,5934,2,

%U 9372,2,6,2,15306,2,24678,2,6,2,39984,2,64662,2,6,2,104646,2,169308,2,6

%N a(1)=1, a(2)=1. a(n) = the sum of the two largest earlier terms which are both coprime to n.

%C From _Robert Israel_, Jun 07 2018: (Start)

%C For n >= 4, a(n) = 2 if n is even.

%C For n >= 7, a(n) == 0 (mod 6) if n is odd.

%C For n >= 9, a(n) = 6 if n == 3 (mod 6). (End)

%H Robert Israel, <a href="/A122457/b122457.txt">Table of n, a(n) for n = 1..10000</a>

%e a(1)=1, a(2)=1, a(3)=2, a(4)=2, a(5)=4, a(6)=2, a(8)=2 are the terms which are coprime to 9 and which occur among {a(1),a(2)...a(8)}. 2 and 4 are the two largest of these terms, so a(9) = 2 + 4 = 6.

%p N:= 100: # for a(1)..a(N)

%p V[1]:= 1: V[2]:= 1:

%p for n from 3 to N do

%p Q:= select(t -> igcd(t,n)=1, [seq(V[i],i=1..n-1)]);

%p j1:= max[index](Q);

%p V[n]:= Q[j1] + max(subsop(j1=NULL,Q))

%p od:

%p seq(V[i],i=1..N); # _Robert Israel_, Jun 07 2018

%t f[s_] := Append[s,Plus @@ Take[Sort[Select[s, GCD[ #, Length[s] + 1] == 1 &]], -2]];Nest[f, {1, 1}, 74] (* _Ray Chandler_, Sep 11 2006 *)

%Y Cf. A122456.

%K nonn,look

%O 1,3

%A _Leroy Quet_, Sep 07 2006

%E Corrected and extended by _Ray Chandler_ and _Robert G. Wilson v_, Sep 11 2006