login
a(n) = least odd prime distinct from earlier elements such that average of first n elements is prime.
6

%I #22 Dec 05 2013 19:56:44

%S 3,7,5,13,37,73,23,71,29,109,103,19,41,293,59,251,683,107,31,223,67,

%T 151,523,127,227,131,347,83,137,197,139,907,163,503,173,389,179,863,

%U 743,211,2671,271,701,281,101,277,4507,367,661,373,883,383,2927,431,541,433

%N a(n) = least odd prime distinct from earlier elements such that average of first n elements is prime.

%C a(n) is the smallest not yet used odd prime such that (a(1)+...+a(n))/n is prime.

%C Conjectured to include all odd prime numbers. - _David W. Wilson_, Nov 23 2012

%H Zak Seidov and Alois P. Heinz, <a href="/A090940/b090940.txt">Table of n, a(n) for n = 1..10000</a>

%e (3+7)/2 = 5, (3+7+5+13)/4 = 7.

%p q:= proc(n) option remember; is(n<3) end:

%p a:= proc(n) option remember; local k, p;

%p if n=1 then 3 else for k while q(k) or

%p irem(s(n-1)+ithprime(k), n, 'p')>0 or not isprime(p)

%p do od; q(k):= true; ithprime(k) fi

%p end:

%p s:= proc(n) option remember; a(n) +`if`(n<2, 0, s(n-1)) end:

%p seq (a(n), n=1..100); # _Alois P. Heinz_, Nov 21 2012

%t a = 3; s = {a}; sm = a; Do[Do[p = Prime[k]; If[FreeQ[s, p] && PrimeQ[(sm + p)/i], sm = sm + p; AppendTo[s, p]; Break[]], {k, 3, 1000000}], {i, 2, 1000}]; s (* _Zak Seidov_, Nov 21 2012 *)

%Y Cf. A090941.

%K nonn

%O 1,1

%A _Amarnath Murthy_, Dec 29 2003

%E Corrected and extended by _Ray Chandler_, Dec 31 2003

%E Definition corrected by _David W. Wilson_, Nov 23 2012