login
Primes p such that Sum_{k=primes<p} (k mod p) and Sum_{k=primes<p} (p mod k) are both prime.
1

%I #22 Feb 16 2021 02:07:45

%S 5,691,2399,3433,5099,6217,7451,9007,10253,10883,16561,21839,23189,

%T 25679,26501,30661,39097,41443,43591,48119,50893,56009,60293,64927,

%U 65537,78979,79829,85853,98669,100403,105491,115981,124783,140557,142547,148013,149953,164113,166219,169249

%N Primes p such that Sum_{k=primes<p} (k mod p) and Sum_{k=primes<p} (p mod k) are both prime.

%C As 0 < k < p, k mod p = k, so Sum_{k = primes<p} (k mod p) = A007504(A000720(A151799(p))) for p > 3. - _David A. Corneth_, Jun 07 2016

%H Robert Israel, <a href="/A274025/b274025.txt">Table of n, a(n) for n = 1..1003</a>

%e 2 mod 5 = 2, 3 mod 5 = 3 and 2 + 3 = 5 is prime;

%e 5 mod 2 = 1, 5 mod 3 = 2 and 1 + 2 = 3 is prime.

%p with(numtheory): P:=proc(q) local a,b,j,k,n; for j from 1 to q do n:=ithprime(j); a:=0; b:=0; for k from 1 to n-1 do

%p if isprime(k) then a:=a+k; b:=b+(n mod k); fi; od;

%p if isprime(a) and isprime(b) then print(n); fi; od; end: P(10^6);

%p # Alternative:

%p N:= 10^6: # to get all entries <= N

%p Primes:= select(isprime,[2,seq(i,i=3..N,2)]):

%p PS:= ListTools:-PartialSums(Primes):

%p count:= 0:

%p for i from 2 to nops(Primes) do

%p n := Primes[i];

%p if isprime(PS[i-1]) and isprime(add(n mod Primes[j],j=1..i-1)) then

%p count:= count+1;

%p A[count]:= n;

%p fi

%p od:

%p seq(A[i],i=1..count); # _Robert Israel_, Jun 07 2016

%o (PARI) is(n) = {if(isprime(n),my(nk,kn,u=prime(primepi(n-1)));

%o forprime(k=2,u,kn+=k;nk+=n%k);isprime(kn)&&isprime(nk),0)} \\ _David A. Corneth_, Jun 07 2016

%Y Cf. A000040, A000720, A007504, A151799.

%K nonn,easy

%O 1,1

%A _Paolo P. Lava_, Jun 07 2016