%I #12 Dec 17 2022 18:28:04
%S 1,2,4,5,10,12,15,20,22,33,36,38,57,60,65,78,81,82,123,126,133,152,
%T 154,165,170,187,198,201,268,270,275,286,299,322,329,376,378,385,396,
%U 399,418,429,442,459,462,473,516,519,692,694,1041,1044,1073,1110,1115,1338
%N a(n+1) = a(n) + p, where p is the largest prime dividing a(n) but not a(n-1), or 1 if there is no such prime.
%C 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).
%C 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.
%H Harvey P. Dale, <a href="/A177186/b177186.txt">Table of n, a(n) for n = 1..1000</a>
%e 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.
%t p[n1_, n2_] := If[pp = Complement[Transpose[FactorInteger[n2]][[1]],
%t 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 *)
%t 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 *)
%o (PARI) invec(v,x)=for(i=1,#v,if(v[i]==x,return(1)));0
%o lastnotin(vi,vx,dft)=forstep(i=#vi,1,-1,if(!invec(vx,vi[i]),return(vi[i])));dft
%o 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
%Y Cf. A076271, A060735, A002620.
%K nonn
%O 1,2
%A _Franklin T. Adams-Watters_, May 04 2010