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.

A102330 Triangle read by rows: n-th row consists of the lexicographically earliest set of n distinct primes whose sum is A068873(n).

Original entry on oeis.org

2, 2, 3, 3, 5, 11, 2, 3, 5, 7, 3, 5, 7, 11, 17, 2, 3, 5, 7, 11, 13, 3, 5, 7, 11, 13, 17, 23, 2, 3, 5, 7, 11, 13, 19, 23, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 31, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 3, 5, 7, 11, 13, 17
Offset: 1

Views

Author

Giovanni Teofilatto, Jan 30 2005

Keywords

Examples

			Triangle begins:
  2
  2,3
  3,5,11
  2,3,5,7
  3,5,7,11,17
  2,3,5,7,11,13
  3,5,7,11,13,17,23
  2,3,5,7,11,13,19,23
  3,5,7,11,13,17,19,23,29
  2,3,5,7,11,13,17,19,23,31
  3,5,7,11,13,17,19,23,29,31,41
  2,3,5,7,11,13,17,19,23,29,31,37
  3,5,7,11,13,17,19,23,29,31,37,41,47
  2,3,5,7,11,13,17,19,23,29,31,37,41,43
  3,5,7,11,13,17,19,23,29,31,37,41,43,47,53
		

Crossrefs

By definition, row sums are A068873.

Programs

  • Maple
    g:= proc(n,k,m) option remember; # lex earliest set of k distinct primes > m with sum n
       local q,v;
      if k = 1 then
        if isprime(n) and n > m then return [n] else return NULL fi
      fi;
      q:= m;
      do
        q:= nextprime(q);
        if n < k*q then return NULL fi;
        v:= procname(n-q,k-1,q);
        if v <> NULL then return [q,op(v)] fi
      od
    end proc:
    f:= proc(k)
    local p,i,v;
    p:= add(ithprime(i),i=1..k)-1;
    do
      p:= nextprime(p);
      v:= g(p,k,0);
      if v <> NULL then return v fi
    od
    end proc:
    for k from 1 to 30 do
      f(k)
    od; # Robert Israel, May 12 2025
  • Mathematica
    (* Computation verified with A068873. *)
    row[n_] := Module[{s, m}, s = Select[{#, Total[#]}& /@ Subsets[ Prime[ Range[n+4]], {n}], PrimeQ[#[[2]]]&]; m = MinimalBy[s, #[[2]]&, 1]; If[s != {}, Return[m[[1, 1]]]]];
    Array[row, 49] // Flatten (* Jean-François Alcover, Apr 23 2020 *)

Extensions

Edited, corrected and extended by Ray Chandler, Feb 02 2005
Edited by N. J. A. Sloane, May 07 2014