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.

A226155 Smallest of four consecutive primes whose average is a triangular number.

This page as a plain text file.
%I A226155 #8 Jun 06 2013 08:08:36
%S A226155 11,47,101,109,241,587,1217,1481,2069,2203,3313,4357,5443,6779,7351,
%T A226155 7489,10723,11927,12239,16267,18911,24517,24733,27953,36571,44839,
%U A226155 51347,55249,55931,56941,60017,64951,68239,68993,70117,75041,86719,87133,92227,94819,98773,111611
%N A226155 Smallest of four consecutive primes whose average is a triangular number.
%p A226155 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 A226155 isA226155 := proc(n)
%p A226155     local p1,p2,p3,a102655 ;
%p A226155     if isprime(n) then
%p A226155         p1 := nextprime(n) ;
%p A226155         p2 := nextprime(p1) ;
%p A226155         p3 := nextprime(p2) ;
%p A226155         a102655 := (n+p1+p2+p3)/4 ;
%p A226155         if type(a102655,'integer') then
%p A226155             if A000217inv(a102655) >= 0 then
%p A226155                 return true;
%p A226155             else
%p A226155                 return false;
%p A226155             end if;
%p A226155         else
%p A226155             return false;
%p A226155         end if;
%p A226155     else
%p A226155         false;
%p A226155     end if;
%p A226155 end proc:
%p A226155 for n from 1 do
%p A226155     p := ithprime(n) ;
%p A226155     if isA226155(p) then
%p A226155         printf("%d,\n",p) ;
%p A226155     end if;
%p A226155 end do: # _R. J. Mathar_, Jun 06 2013
%o A226155 (C)
%o A226155 #include <stdio.h>
%o A226155 #include <stdlib.h>
%o A226155 #include <math.h>
%o A226155 #define TOP (1ULL<<30)
%o A226155 int main() {
%o A226155   unsigned long long i, j, p1, p2, p3, r, s;
%o A226155   unsigned char *c = (unsigned char *)malloc(TOP/8);
%o A226155   memset(c, 0, TOP/8);
%o A226155   for (i=3; i < TOP; i+=2)
%o A226155     if ((c[i>>4] & (1<<((i>>1) & 7)))==0 /*&& i<(1ULL<<32)*/)
%o A226155         for (j=i*i>>1; j<TOP; j+=i)  c[j>>3] |= 1 << (j&7);
%o A226155   for (p3=2, p2=3, p1=5, i=7; i < TOP; i+=2)
%o A226155     if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {
%o A226155       s = p3 + p2 + p1 + i;
%o A226155       if (s%4==0) {
%o A226155         s/=4;
%o A226155         r = sqrt(s*2);
%o A226155         if (r*(r+1)==s*2) printf("%llu, ", p3);
%o A226155       }
%o A226155       p3 = p2, p2 = p1, p1 = i;
%o A226155     }
%o A226155   return 0;
%o A226155 }
%Y A226155 Cf. A102655, A226151 A226153, A226154.
%K A226155 nonn
%O A226155 1,1
%A A226155 _Alex Ratushnyak_, May 28 2013