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.

A226145 Numbers n such that triangular(n) is a sum of three successive primes.

Original entry on oeis.org

4, 5, 61, 82, 142, 166, 202, 233, 337, 394, 418, 422, 446, 493, 538, 661, 670, 841, 886, 1101, 1177, 1234, 1237, 1266, 1322, 1426, 1441, 1477, 1593, 1642, 1690, 1713, 1765, 1789, 1798, 1885, 1901, 1930, 1941, 2041, 2061, 2098, 2101, 2161, 2218, 2277, 2305, 2350, 2614
Offset: 1

Views

Author

Alex Ratushnyak, May 28 2013

Keywords

Examples

			For k = 5, triangular(k) = triangular(5) = 15. 15/3 = 5. The next prime larger or equal to 5 is 5. The prime before 5 is 3. If there is a triple of consecutive primes that sum to 15 then 3 and 5 are two of them. Then the third one must be 15 - 3 - 5 = 7. 7 is prime and 3, 5 and 7 are consecutive primes (as 7 is the next larger prime than 5 or the previous prime to 3). Therefore, k = 5 is in the sequence. - _David A. Corneth_, Sep 18 2019
		

Crossrefs

Cf. A167788 (the corresponding triangular numbers).

Programs

  • C
    #include 
    #include 
    #include 
    #define TOP (1ULL<<30)
    int main() {
      unsigned long long i, j, p1, p2, r, s;
      unsigned char *c = (unsigned char *)malloc(TOP/8);
      memset(c, 0, TOP/8);
      for (i=3; i < TOP; i+=2)
        if ((c[i>>4] & (1<<((i>>1) & 7)))==0 /*&& i<(1ULL<<32)*/)
            for (j=i*i>>1; j>3] |= 1 << (j&7);
      for (p2=2, p1=3, i=5; i < TOP; i+=2)
        if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {
          s = p2 + p1 + i;
          r = sqrt(s*2);
          if (r*(r+1)==s*2) printf("%llu, ", r);
          p2 = p1, p1 = i;
        }
      return 0;
    }
    
  • Mathematica
    (Sqrt[8#+1]-1)/2&/@Select[Total/@Partition[Prime[Range[ 100000]],3,1], OddQ[ Sqrt[8#+1]]&] (* Harvey P. Dale, Sep 18 2019 *)
  • PARI
    upto(n) = {my(res = List(), t = 10); for(i = 5, n, c = t/3; p = nextprime(ceil(c)); q = precprime(p - 1); r = t - p - q; if(isprime(r) && nextprime(r + 1) == q || nextprime(p + 1) == r, listput(res, i - 1)); t+=i); res}

A226148 Smallest of three consecutive primes whose sum is a triangular number.

Original entry on oeis.org

2, 3, 619, 1123, 3373, 4603, 6829, 9067, 18973, 25933, 29179, 29741, 33211, 40583, 48313, 72923, 74923, 117991, 130973, 202201, 231067, 253993, 255217, 267317, 291491, 339139, 346309, 363829, 423191, 449621, 476279, 489337, 519487, 533713, 539093, 592507, 602603, 621133
Offset: 1

Views

Author

Alex Ratushnyak, May 28 2013

Keywords

Crossrefs

Cf. A167788 (the resulting triangular numbers).

Programs

  • C
    #include 
    #include 
    #include 
    #define TOP (1ULL<<30)
    int main() {
      unsigned long long i, j, p1, p2, r, s;
      unsigned char *c = (unsigned char *)malloc(TOP/8);
      memset(c, 0, TOP/8);
      for (i=3; i < TOP; i+=2)
        if ((c[i>>4] & (1<<((i>>1) & 7)))==0 /*&& i<(1ULL<<32)*/)
            for (j=i*i>>1; j>3] |= 1 << (j&7);
      for (p2=2, p1=3, i=5; i < TOP; i+=2)
        if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {
          s = p2 + p1 + i;
          r = sqrt(s*2);
          if (r*(r+1)==s*2) printf("%llu, ", p2);
          p2 = p1, p1 = i;
        }
      return 0;
    }
  • Maple
    R:= 2: count:= 1:
    for k from 1 while count < 100 do
     for j from 1 to 2 do
      m:= 4*k+j;
      x:= m*(m+1)/2;
      q= prevprime(ceil(x/3));
      p:= prevprime(q); r:= nextprime(q);
      t:= p+q+r;
      if t < x then while t < x do p:= q; q:= r; r:= nextprime(r); t:=p+q+r od
      elif t > x then while t > x do r:= q; q:= p; p:= prevprime(p); t:= p+q+r od
      fi;
      if t = x then  R:= R,p; count:= count+1; fi
    od od :
    R; # Robert Israel, Oct 18 2021
Showing 1-2 of 2 results.