login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A226155 Smallest of four consecutive primes whose average is a triangular number. 0

%I #8 Jun 06 2013 08:08:36

%S 11,47,101,109,241,587,1217,1481,2069,2203,3313,4357,5443,6779,7351,

%T 7489,10723,11927,12239,16267,18911,24517,24733,27953,36571,44839,

%U 51347,55249,55931,56941,60017,64951,68239,68993,70117,75041,86719,87133,92227,94819,98773,111611

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

%p 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 isA226155 := proc(n)

%p local p1,p2,p3,a102655 ;

%p if isprime(n) then

%p p1 := nextprime(n) ;

%p p2 := nextprime(p1) ;

%p p3 := nextprime(p2) ;

%p a102655 := (n+p1+p2+p3)/4 ;

%p if type(a102655,'integer') then

%p if A000217inv(a102655) >= 0 then

%p return true;

%p else

%p return false;

%p end if;

%p else

%p return false;

%p end if;

%p else

%p false;

%p end if;

%p end proc:

%p for n from 1 do

%p p := ithprime(n) ;

%p if isA226155(p) then

%p printf("%d,\n",p) ;

%p end if;

%p end do: # _R. J. Mathar_, Jun 06 2013

%o (C)

%o #include <stdio.h>

%o #include <stdlib.h>

%o #include <math.h>

%o #define TOP (1ULL<<30)

%o int main() {

%o unsigned long long i, j, p1, p2, p3, r, s;

%o unsigned char *c = (unsigned char *)malloc(TOP/8);

%o memset(c, 0, TOP/8);

%o for (i=3; i < TOP; i+=2)

%o if ((c[i>>4] & (1<<((i>>1) & 7)))==0 /*&& i<(1ULL<<32)*/)

%o for (j=i*i>>1; j<TOP; j+=i) c[j>>3] |= 1 << (j&7);

%o for (p3=2, p2=3, p1=5, i=7; i < TOP; i+=2)

%o if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {

%o s = p3 + p2 + p1 + i;

%o if (s%4==0) {

%o s/=4;

%o r = sqrt(s*2);

%o if (r*(r+1)==s*2) printf("%llu, ", p3);

%o }

%o p3 = p2, p2 = p1, p1 = i;

%o }

%o return 0;

%o }

%Y Cf. A102655, A226151 A226153, A226154.

%K nonn

%O 1,1

%A _Alex Ratushnyak_, May 28 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 09:04 EDT 2024. Contains 371240 sequences. (Running on oeis4.)