OFFSET
1,2
LINKS
Samuel Harkness, Table of n, a(n) for n = 1..10000
EXAMPLE
To find a(8), we look at the last two terms of the sequence so far (0,4,1,3,2,5,9). Their product 5*9=45 can be expressed as factor pairs (1,45), (3,15), (5,9) of which 3 and 15 have the smallest unused difference (12). We cannot use 9-5=4 because 4 is already in the sequence, so a(8)=12.
MAPLE
S:= {0, 4, 1}:
R:= 0, 4, 1:
for n from 4 to 100 do
s:= R[-1]*R[-2];
cands:= select(type, map(t -> s/t - t, numtheory:-divisors(s)), posint) minus S;
if cands = {} then printf("Sequence stops at n = %d\n", n); break fi;
x:= min(cands);
R:= R, x;
S:= S union {x};
od:
R; # Robert Israel, Mar 01 2023
MATHEMATICA
K = {0, 4, 1}; For[a = 4, a < 65, a++, If[q == 0, Print["Finite List, length ", Length[K]]; Break[]]; d = Divisors[K[[a - 1]]*K[[a - 2]]]; If[OddQ[Length[d]], d = Delete[d, (Length[d] + 1)/2]]; For[q = Length[d]/2, q > 0, q--, If[!MemberQ[K, d[[Length[d] - q + 1]] - d[[q]]], AppendTo[K, d[[Length[d] - q + 1]] - d[[q]]]; Break[]]]]; Print[K] (* Samuel Harkness, Feb 28 2023 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Neal Gersh Tolunsky, Feb 27 2023
STATUS
approved