A160256 a(1)=1, a(2)=2. For n >=3, a(n) = the smallest positive integer not occurring earlier in the sequence such that a(n)*a(n-1)/a(n-2) is an integer.
1, 2, 3, 4, 6, 8, 9, 16, 18, 24, 12, 10, 30, 5, 36, 15, 48, 20, 60, 7, 120, 14, 180, 21, 240, 28, 300, 35, 360, 42, 420, 11, 840, 22, 1260, 33, 1680, 44, 2100, 55, 2520, 66, 2940, 77, 3360, 88, 3780, 110, 378, 165, 126, 220, 63, 440, 189, 880, 567, 1760
Offset: 1
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..130000
- Alois P. Heinz, Color plot of first 600 terms
Crossrefs
Programs
-
Haskell
import Data.List (delete) a160256 n = a160256_list !! (n-1) a160256_list = 1 : 2 : f 1 2 [3..] where f u v ws = g ws where g (x:xs) | mod (x * v) u == 0 = x : f v x (delete x ws) | otherwise = g xs -- Reinhard Zumkeller, Jan 31 2014
-
Maple
b:= proc(n) option remember; false end: a:= proc(n) option remember; local k, m; if n<3 then b(n):=true; n else m:= denom(a(n-1)/a(n-2)); for k from m by m while b(k) do od; b(k):= true; k fi end: seq(a(n), n=1..100); # Alois P. Heinz, May 16 2009 # alternative A160256 := proc(n) local r,m,a,fnd,i ; option remember; if n <=2 then n; else r := procname(n-2)/igcd(procname(n-1),procname(n-2)) ; for m from 1 do a := m*r ; fnd := false; for i from 1 to n-1 do if procname(i) = a then fnd := true; break; end if; end do: if not fnd then return a ; end if; end do: end if; end proc: seq(A160256(n),n=1..40) ; # R. J. Mathar, Jul 30 2024
-
Mathematica
f[s_List] := Block[{k = 1, m = Denominator[ s[[ -1]]/s[[ -2]]]}, While[ MemberQ[s, k*m] || Mod[k*m*s[[ -1]], s[[ -2]]] != 0, k++ ]; Append[s, k*m]]; Nest[f, {1, 2}, 56] (* Robert G. Wilson v, May 17 2009 *)
-
PARI
LQ(nMax)={my(a1=1,a2=1,L=1/*least unseen number*/,S=[]/*used numbers above L*/); while(1, /*cleanup*/ while( setsearch(S,L),S=setminus(S,Set(L));L++); /*search*/ for(a=L,nMax, a*a2%a1 & next; setsearch(S,a) & next; print1(a","); a1=a2; S=setunion(S,Set(a2=a)); next(2));return(L))} \\ M. F. Hasler, May 06 2009
-
PARI
L=10^4;a=vector(L);b=[1,2];a[1]=1;a[2]=2;sb=2;P2=2;pending=[];sp=0;for(n=3,L,if(issquare(n),b=vecsort(concat(b,pending));sb=n-1;while(sb>=2*P2,P2*=2);sp=0;pending=[]);c=a[n-2]/gcd(a[n-2],a[n-1]);u=0;while(1,u+=c;found=0;s=0;pow2=P2;while(pow2,s2=s+pow2;if((s2<=sb)&&(b[s2]<=u),s=s2);pow2\=2);if((s>0)&&(b[s]==u),found=1,for(i=1,sp,if(pending[i]==u,found=1;break)));if(found==0,break));a[n]=u;pending=concat(pending,u);sp++);a \\ Robert Gerbicz, May 16 2009
-
Python
from math import gcd A160256_list, l1, l2, m, b = [1, 2], 2, 1, 1, {1, 2} for _ in range(10**3): i = m while True: if not i in b: A160256_list.append(i) l1, l2, m = i, l1, l1//gcd(l1, i) b.add(i) break i += m # Chai Wah Wu, Dec 09 2014
Extensions
More terms from M. F. Hasler, May 06 2009
Edited by N. J. A. Sloane, May 16 2009
Comments