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.

Showing 1-2 of 2 results.

A051912 a(n) is the smallest integer such that the sum of any three ordered terms a(k), k <= n, is unique.

Original entry on oeis.org

0, 1, 4, 13, 32, 71, 124, 218, 375, 572, 744, 1208, 1556, 2441, 3097, 4047, 5297, 6703, 7838, 10986, 12331, 15464, 19143, 24545, 28973, 34405, 37768, 45863, 50876, 61371, 68302, 77917, 88544, 101916, 122031, 131624, 148574, 171236, 197814
Offset: 0

Views

Author

Wouter Meeussen, Dec 17 1999

Keywords

Examples

			Three terms chosen from {0,1,4} can be 0+0+0; 0+0+1; 0+1+1; 1+1+1; 0+0+4; 0+1+4; 1+1+4; 0+4+4; 1+4+4; 4+4+4 are all distinct (3*4*5/6 = 10 terms), so a(2) = 4 is the next integer of the sequence after 0 and 1.
		

Crossrefs

Row 3 of A365515.

Programs

  • Maple
    A[0]:= 0: S:= {0}: S2:= {0}: S3:= {0}:
    for i from 1 to 40 do
      for x from A[i-1] do
        if (map(t -> t+x,S2) intersect S3 = {}) and (map(t -> t+2*x, S) intersect S3 = {}) then
         A[i]:= x;
         S3:= S3 union map(t -> t+x,S2) union map(t -> t+2*x, S) union {3*x};
         S2:= S2 union map(t -> t+x, S) union {2*x};
         S:= S union {x};
         break
        fi
      od
    od:
    seq(A[i],i=0..40); # Robert Israel, Jul 01 2019
  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := a[n] = For[A0 = Array[a, n, 0]; an = a[n-1] + 1, True, an++, A1 = Append[A0, an]; A2 = Flatten[Table[A1[[{i, j, k}]], {i, 1, n+1}, {j, i, n+1}, {k, j, n+1}], 2]; A3 = Sort[Total /@ A2]; If[Length[A3] == Length[Union[A3]], Return[an]]]; Table[an = a[n]; Print["a(", n, ") = ", an]; an, {n, 0, 38}] (* Jean-François Alcover, Nov 24 2016 *)
  • Python
    from itertools import count, islice
    def A051912_gen(): # generator of terms
        aset1, aset2, aset3, alist = set(), set(), set(), []
        for k in count(0):
            bset2, bset3 = {k<<1}, {3*k}
            if 3*k not in aset3:
                for d in aset1:
                    if (m:=d+(k<<1)) in aset3:
                        break
                    bset2.add(d+k)
                    bset3.add(m)
                else:
                    for d in aset2:
                        if (m:=d+k) in aset3:
                            break
                        bset3.add(m)
                    else:
                        yield k
                        alist.append(k)
                        aset1.add(k)
                        aset2 |= bset2
                        aset3 |= bset3
    A051912_list = list(islice(A051912_gen(),20)) # Chai Wah Wu, Sep 01 2023

Extensions

More terms from Naohiro Nomoto, Jul 22 2001

A036241 a(1)=1, a(2)=2, a(3)=3; for n >= 3, a(n) is smallest number such that all a(i) for 1 <= i <= n are distinct, all a(i)+a(j) for 1 <= i < j <= n are distinct and all a(i)+a(j)+a(k) for 1 <= i < j < k <= n are distinct.

Original entry on oeis.org

1, 2, 3, 5, 8, 14, 25, 45, 82, 140, 235, 388, 559, 839, 1286, 1582, 2221, 3144, 4071, 5795, 6872, 9204, 11524, 13796, 17686, 21489, 26019, 31080, 37742, 45067, 53144, 58365, 67917, 78484, 91767, 106513, 118600, 133486, 147633, 166034, 174717
Offset: 1

Views

Author

Keywords

Examples

			For {1,2,3,4} we have 1+4 = 2+3, so a(4) is not 4. For {1,2,3,5} the terms 1, 2, 3, 5 are distinct, the sums 1+2, 1+3, 1+5, 2+3, 2+5, 3+5 are distinct and the sums 1+2+3, 1+2+5, 1+3+5, 2+3+5 are distinct, so a(4) = 5.
		

References

  • Letter from V. Jooste, Pretoria, South Africa, Sep. 8, 1975.

Crossrefs

Programs

  • Haskell
    import qualified Data.Set as Set (null, map)
    import Data.Set (empty, fromList, toList, intersect, union)
    a036241 n = a036241_list !! (n-1)
    a036241_list = f [1..] [] empty empty where
       f (x:xs) ys s2 s3
        | null (s2' `intersect` y2s) && null (s3' `intersect` y3s)
          = x : f xs (x:ys) (fromList s2' `union` s2) (fromList s3' `union` s3)
        | otherwise = f xs ys s2 s3
        where s2' = sort $ map (x +) ys
              s3' = sort $ map (x +) y2s
              y2s = toList s2
              y3s = toList s3
    -- Reinhard Zumkeller, Oct 02 2011
    
  • Mathematica
    a[1]=1; a[2]=2; a[3]=3; a[n_] := a[n] = Catch[For[an = a[n-1] + 1, True, an++, a[n] = an; t2 = Flatten[Table[a[i] + a[j], {i, 1, n}, {j, i+1, n}]]; If[n*(n-1)/2 == Length[Union[t2]], t3 = Flatten[Table[a[i] + a[j] + a[k], {i, 1, n}, {j, i+1, n}, {k, j+1, n}]]; If[ n*(n-1)*(n-2)/6 == Length[Union[t3]], Throw[an]]]]]; Table[Print[a[n]]; a[n], {n, 1, 41}] (* Jean-François Alcover, Jul 24 2012 *)
  • PARI
    {unique(v)=local(b); b=1; for(j=2,length(v),if(v[j-1]==v[j],b=0)); b}
    {newsort(u,v,q)=local(s); s=[]; for(i=1,length(v),s=concat(s,v[i]+q)); vecsort(concat(u,s))}
    {m=175000; print1(1,",",2,",",3,","); w1=[1,2,3]; w2=[3,4,5]; w3=[6]; q=4; while(q
    				
  • Python
    from itertools import count, islice
    def A036241_gen(): # generator of terms
        aset2, aset3 = {3,4,5}, {6}
        yield from (alist:=[1,2,3])
        for k in count(4):
            bset2, bset3 = set(), set()
            for a in alist:
                if (b2:=a+k) in aset2:
                    break
                bset2.add(b2)
            else:
                for a2 in aset2:
                    if (b3:=a2+k) in aset3:
                        break
                    bset3.add(b3)
                else:
                    yield k
                    alist.append(k)
                    aset2.update(bset2)
                    aset3.update(bset3)
    A036241_list = list(islice(A036241_gen(),20)) # Chai Wah Wu, Sep 10 2023

Extensions

Better description and more terms from Naohiro Nomoto, Jul 02 2001
Edited by and terms a(30) to a(41) from Klaus Brockhaus, May 21 2003
Showing 1-2 of 2 results.