login
Least prime p such that n = p + q - r for some primes q and r with q > p.
5

%I #5 Apr 29 2016 00:12:12

%S 3,2,2,2,2,2,2,2,3,2,2,2,2,2,3,2,2,2,2,2,3,2,2,2,3,2,3,2,2,2,2,2,3,2,

%T 3,2,2,2,3,2,2,2,2,2,3,2,2,2,3,2,3,2,2,2,3,2,3,2,2,2,2,2,3,2,3,2,2,2,

%U 3,2,2,2,2,2,3,2,3,2,2,2,3,2,2,2,3,2

%N Least prime p such that n = p + q - r for some primes q and r with q > p.

%C p = 3 when n is an odd nonprime and p = 2 otherwise, so that 3 appears in positions given by A014076.

%H Clark Kimberling, <a href="/A270003/b270003.txt">Table of n, a(n) for n = 1..10000</a>

%e n p q r

%e 1 3 5 7

%e 2 2 3 3

%e 3 2 3 2

%e 4 2 5 3

%e 5 2 5 2

%e 6 2 7 3

%e 7 2 7 2

%t t = Join[{{1, {3, 5, 7}}, {2, {2, 3, 3}}}, Table[If[PrimeQ[n], {n, {2, n, 2}}, p = If[EvenQ[2 + NextPrime[n, 1] - n], 3, 2]; NestWhile[# + 1 &, 1, ! PrimeQ[r = (p + (q = NextPrime[n, #])) - n] &]; {n, {p, q, r}}], {n, 3, 300}]];

%t Map[#[[2]][[1]] &, t] (* p, A270003 *)

%t Map[#[[2]][[2]] &, t] (* q, A270753 *)

%t Map[#[[2]][[3]] &, t] (* r, A271353 *)

%t (* _Peter J. C. Moses_, Apr 26 2016 *)

%o (PARI) a(n)=if(n%2 && !isprime(n), 3, 2) \\ _Charles R Greathouse IV_, Apr 29 2016

%Y Cf. A000040, A270753, A271353.

%K nonn,easy

%O 1,1

%A _Clark Kimberling_, Apr 26 2016