cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A160256 #37 Oct 06 2024 20:43:54
%S A160256 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,
%T A160256 28,300,35,360,42,420,11,840,22,1260,33,1680,44,2100,55,2520,66,2940,
%U A160256 77,3360,88,3780,110,378,165,126,220,63,440,189,880,567,1760
%N 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.
%C A160256 Is this sequence a permutation of the positive integers?
%C A160256 a(n+2)*a(n+1)/a(n) = A160257(n).
%C A160256 From _Alois P. Heinz_, May 07 2009: (Start)
%C A160256 After computing about 10^7 elements of A160256 we have
%C A160256 a(10000000) = 2099597439752627193722111679586865799879114417
%C A160256 a(10000001) = 992131130100042530286371815859160
%C A160256 Largest element so far:
%C A160256 a(8968546) = 24941014474345046106920043019655502800839523254002490663461\
%C A160256 524119982890708516899294655028121578883343551450916846444559467340663409\
%C A160256 549447588184641816
%C A160256 Still missing:
%C A160256 19, 23, 27, 29, 31, 32, 37, 38, 41, 43, 45, 46, 47, 53, 54, 57, 58, 59,
%C A160256 61, 62, 64, 67, 69, 71, 72, 73, 74, 76, 79, 81, 82, 83, 86, 87, 89, 90,
%C A160256 92, 93, 94, 95, 96, 97, 101, 103, 105, 106, 107, 108, 109, 111, 112, 113,
%C A160256 114, 115, 116, 118, 122, 123, 124, 125, 127, 128, 129, 131, 133, 134, ...
%C A160256 Primes in sequence so far:
%C A160256 2, 3, 5, 7, 11, 13, 17
%C A160256 The sequence consists of two subsequences, even (=red) and odd (=blue), see plot. (End)
%C A160256 a(n) is the least multiple of a(n-2)/gcd(a(n-1),a(n-2)) that has not previously occurred. - _Thomas Ordowski_, Jul 15 2015
%H A160256 Alois P. Heinz, <a href="/A160256/b160256.txt">Table of n, a(n) for n = 1..130000</a>
%H A160256 Alois P. Heinz, <a href="/A160256/a160256_plot.jpg">Color plot of first 600 terms</a>
%p A160256 b:= proc(n) option remember; false end:
%p A160256 a:= proc(n) option remember; local k, m;
%p A160256       if n<3 then b(n):=true; n
%p A160256     else m:= denom(a(n-1)/a(n-2));
%p A160256          for k from m by m while b(k) do od;
%p A160256          b(k):= true; k
%p A160256       fi
%p A160256     end:
%p A160256 seq(a(n), n=1..100); # _Alois P. Heinz_, May 16 2009
%p A160256 # alternative
%p A160256 A160256 := proc(n)
%p A160256     local r,m,a,fnd,i ;
%p A160256     option remember;
%p A160256     if n <=2 then
%p A160256         n;
%p A160256     else
%p A160256         r := procname(n-2)/igcd(procname(n-1),procname(n-2)) ;
%p A160256         for m from 1 do
%p A160256             a := m*r ;
%p A160256             fnd := false;
%p A160256             for i from 1 to n-1 do
%p A160256                 if procname(i) = a then
%p A160256                     fnd := true;
%p A160256                     break;
%p A160256                 end if;
%p A160256             end do:
%p A160256             if not fnd then
%p A160256                 return a ;
%p A160256             end if;
%p A160256         end do:
%p A160256     end if;
%p A160256 end proc:
%p A160256 seq(A160256(n),n=1..40) ; # _R. J. Mathar_, Jul 30 2024
%t A160256 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 *)
%o A160256 (PARI)
%o A160256 LQ(nMax)={my(a1=1,a2=1,L=1/*least unseen number*/,S=[]/*used numbers above L*/);
%o A160256 while(1, /*cleanup*/ while( setsearch(S,L),S=setminus(S,Set(L));L++);
%o A160256 /*search*/ for(a=L,nMax, a*a2%a1 & next; setsearch(S,a) & next;
%o A160256 print1(a","); a1=a2; S=setunion(S,Set(a2=a)); next(2));return(L))} \\ _M. F. Hasler_, May 06 2009
%o A160256 (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
%o A160256 (Haskell)
%o A160256 import Data.List (delete)
%o A160256 a160256 n = a160256_list !! (n-1)
%o A160256 a160256_list = 1 : 2 : f 1 2 [3..] where
%o A160256    f u v ws = g ws where
%o A160256      g (x:xs) | mod (x * v) u == 0 = x : f v x (delete x ws)
%o A160256               | otherwise          = g xs
%o A160256 -- _Reinhard Zumkeller_, Jan 31 2014
%o A160256 (Python)
%o A160256 from math import gcd
%o A160256 A160256_list, l1, l2, m, b = [1, 2], 2, 1, 1, {1, 2}
%o A160256 for _ in range(10**3):
%o A160256     i = m
%o A160256     while True:
%o A160256         if not i in b:
%o A160256             A160256_list.append(i)
%o A160256             l1, l2, m = i, l1, l1//gcd(l1, i)
%o A160256             b.add(i)
%o A160256             break
%o A160256         i += m # _Chai Wah Wu_, Dec 09 2014
%Y A160256 Cf. A075075, A160257, A151413, A160218, A151546, A064413.
%Y A160256 For records see A151545, A151547.
%K A160256 nonn,look
%O A160256 1,2
%A A160256 _Leroy Quet_, May 06 2009
%E A160256 More terms from _M. F. Hasler_, May 06 2009
%E A160256 Edited by _N. J. A. Sloane_, May 16 2009