%I #17 Nov 17 2020 23:09:06
%S 3,29,11,13,17,29,23,29,31,37,41,71,47,61,73,61,73,71,73,79,97,89,97,
%T 113,127,107,137,131,127,139,149,173,157,151,157,173,167,173,227,223,
%U 197,293,211,239,211,251,227,239,563,239,269,397,283,409,283,281,283
%N Final prime in sequence of primes starting with prime(n) and having prime sum (see A071194), or -1 if no such sequence exists.
%C The length of the sequence is given in A071194.
%H Charles R Greathouse IV, <a href="/A071195/b071195.txt">Table of n, a(n) for n = 1..10000</a>
%e n=2: p(2)=3, 3+7+11+13+17+19+23+29 = 127 is the shortest partial sum with initial prime 3; it ends with p(10) = 29 = a(2);
%e n=6: p(6)=13, 13+17+19+23+29 = 101, so the end-prime = a(6) = 29.
%t Prime@ Table[k = 1; While[! PrimeQ@ Total@ Prime@ Range[n, n + k], k++]; n + k, {n, 57}] (* _Michael De Vlieger_, Mar 25 2017 *)
%o (PARI) a(n,p=prime(n))=my(q=p); while(!isprime(p+=q=nextprime(q+1)),);q
%o apply(p->a(0,p), primes(30)) \\ _Charles R Greathouse IV_, Jun 16 2015
%Y Cf. A071194, A071196, A071197, A071198.
%K nonn
%O 1,1
%A _Labos Elemer_, May 16 2002
%E Edited and escape clause added by _N. J. A. Sloane_, Nov 17 2020