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.

A226154 Smallest of four consecutive primes whose sum is a triangular number.

This page as a plain text file.
%I A226154 #8 Jun 06 2013 08:08:51
%S A226154 5,23,191,389,449,2593,3011,5167,5639,5851,8669,18839,25463,26953,
%T A226154 28843,38561,47963,51907,57859,65419,67789,77711,78301,79889,96013,
%U A226154 102023,128119,139501,163417,192037,206233,234083,273601,299329,324593,354677,359323,362723,417451
%N A226154 Smallest of four consecutive primes whose sum is a triangular number.
%p A226154 A000217inv:=proc(n) local t1; t1:=floor(sqrt(2*n)); if n = t1*(t1+1)/2 then return t1 ; else return -1; end if; end;
%p A226154 isA226154 := proc(n)
%p A226154     local p1,p2,p3,a034963 ;
%p A226154     if isprime(n) then
%p A226154         p1 := nextprime(n) ;
%p A226154         p2 := nextprime(p1) ;
%p A226154         p3 := nextprime(p2) ;
%p A226154         a034963 := n+p1+p2+p3 ;
%p A226154         if A000217inv(a034963) >= 0 then
%p A226154             return true;
%p A226154         else
%p A226154             return false;
%p A226154         end if;
%p A226154     else
%p A226154         false;
%p A226154     end if;
%p A226154 end proc:
%p A226154 for n from 1 do
%p A226154     p := ithprime(n) ;
%p A226154     if isA226154(p) then
%p A226154         printf("%d,\n",p) ;
%p A226154     end if;
%p A226154 end do: # _R. J. Mathar_, Jun 06 2013
%o A226154 (C)
%o A226154 #include <stdio.h>
%o A226154 #include <stdlib.h>
%o A226154 #include <math.h>
%o A226154 #define TOP (1ULL<<30)
%o A226154 int main() {
%o A226154   unsigned long long i, j, p1, p2, p3, r, s;
%o A226154   unsigned char *c = (unsigned char *)malloc(TOP/8);
%o A226154   memset(c, 0, TOP/8);
%o A226154   for (i=3; i < TOP; i+=2)
%o A226154     if ((c[i>>4] & (1<<((i>>1) & 7)))==0 /*&& i<(1ULL<<32)*/)
%o A226154         for (j=i*i>>1; j<TOP; j+=i)  c[j>>3] |= 1 << (j&7);
%o A226154   for (p3=2, p2=3, p1=5, i=7; i < TOP; i+=2)
%o A226154     if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {
%o A226154       s = p3 + p2 + p1 + i;
%o A226154       r = sqrt(s*2);
%o A226154       if (r*(r+1)==s*2) printf("%llu, ", p3);
%o A226154       p3 = p2, p2 = p1, p1 = i;
%o A226154     }
%o A226154   return 0;
%o A226154 }
%Y A226154 Cf. A034963, A226151.
%K A226154 nonn
%O A226154 1,1
%A A226154 _Alex Ratushnyak_, May 28 2013