login
Starting with n-1 go on adding the numbers less than n and coprime to it in descending order until one gets a prime. a(n) = this prime, or 0 if no such number exists.
1

%I #12 Feb 24 2016 16:37:33

%S 0,0,2,3,7,5,11,7,0,19,19,11,23,13,53,0,31,17,0,19,0,101,43,23,47,131,

%T 0,139,0,29,59,31,233,223,67,179,71,37,373,109,79,41,83,43,269,457,0,

%U 47,431,139,641,313,103,53,107,251,613,643,0,59,0,61,587,0,127,521,131,67

%N Starting with n-1 go on adding the numbers less than n and coprime to it in descending order until one gets a prime. a(n) = this prime, or 0 if no such number exists.

%C a(p+1) = p, p is a prime.

%C If n is prime and 2n-3 is not prime, then a(n) = 0. - _David Wasserman_, Jan 27 2005

%C There are 105 zeros in the first 1000 terms. - _Harvey P. Dale_, Feb 24 2016

%H Harvey P. Dale, <a href="/A085107/b085107.txt">Table of n, a(n) for n = 1..1000</a>

%e a(10) = 9 + 7 + 3 = 19.

%t cp[n_]:=SelectFirst[Accumulate[Select[Range[n,1,-1],CoprimeQ[ #,n]&]], PrimeQ]/._Missing->0; Array[cp,70] (* The program uses the SelectFirst function from Mathematica version 10 *) (* _Harvey P. Dale_, Feb 24 2016 *)

%K nonn

%O 1,3

%A _Amarnath Murthy_ and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jul 04 2003

%E More terms from _David Wasserman_, Jan 27 2005