OFFSET
1,2
COMMENTS
Setting a(1) = 1 is arbitrary; since 1 has no prime divisors, we must then have p = 1 => a(2) = 2, without reference to a(0).
There are three cases where p = 1: n=1 (a(n)=1); n=3 (a(n)=4); n=17 (a(n)=81); and no others through n = 10000. Except that there cannot be such cases consecutively, p=1 iff a(n) is a prime power.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
After a(9)=22, a(10)=33, the prime divisors of a(10) are 3 and 11; 11 divides 22, so p=3, and a(11)=36.
MATHEMATICA
p[n1_, n2_] := If[pp = Complement[Transpose[FactorInteger[n2]][[1]],
Transpose[FactorInteger[n1]][[1]]]; pp == {}, 1, Last[pp]]; a[1] = 1; a[2] = 2; a[n_] := a[n] = a[n-1] + p[a[n-2], a[n-1]]; Table[a[n], {n, 56}] (* Jean-François Alcover, Sep 02 2011 *)
nxt[{a_, b_}]:={b, b+Max[1, Complement[FactorInteger[b][[All, 1]], FactorInteger[ a] [[All, 1]]]]}; NestList[nxt, {1, 2}, 60][[All, 1]] (* Harvey P. Dale, Dec 17 2022 *)
PROG
(PARI) invec(v, x)=for(i=1, #v, if(v[i]==x, return(1))); 0
lastnotin(vi, vx, dft)=forstep(i=#vi, 1, -1, if(!invec(vx, vi[i]), return(vi[i]))); dft
al(n)=local(r); r=vector(n); r[1]=1; r[2]=2; for(k=3, n, r[k]=r[k-1]+lastnotin(factor(r[k-1])[, 1]~, factor(r[k-2])[, 1]~, 1)); r
CROSSREFS
KEYWORD
nonn
AUTHOR
Franklin T. Adams-Watters, May 04 2010
STATUS
approved