login
If 2n-1 is prime then a(n) = 2n-1, otherwise a(n) = 0.
9

%I #34 Sep 08 2022 08:45:11

%S 0,3,5,7,0,11,13,0,17,19,0,23,0,0,29,31,0,0,37,0,41,43,0,47,0,0,53,0,

%T 0,59,61,0,0,67,0,71,73,0,0,79,0,83,0,0,89,0,0,0,97,0,101,103,0,107,

%U 109,0,113,0,0,0,0,0,0,127,0,131,0,0,137,139,0,0,0,0,149,151,0,0,157,0,0,163

%N If 2n-1 is prime then a(n) = 2n-1, otherwise a(n) = 0.

%C Previous name was: Starting with n+(n-1) go on adding n-2, then n-3, etc. until one gets a prime; a(n) = smallest prime in n+(n-1)+(n-2)+...+(n-i) (with the least i that gives a prime), or 0 if no such prime exists.

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

%F If 2n-1 is prime then a(n) = 2n-1, otherwise a(n) = 0. - _David Wasserman_, Jan 25 2005

%F a(A098090(n)-1)=2*A098090(n)-3; a(n)=(2*n-1)*A101264(n-1). - _Reinhard Zumkeller_, Sep 14 2006

%F a(n+1) = (4n-1)!! mod (2n+1)^2; by Gauss generalization of the Wilson's theorem. - _Thomas Ordowski_, Jul 23 2016

%e a(8) = 0 as there is no prime in the partial sum of the finite sequence 8,7,6,5,4,3,2,1.

%e a(7) = 13 = 7 + 6.

%t apr[n_]:=Module[{cl=Select[Rest[Accumulate[Range[n,1,-1]]],PrimeQ, 1]}, If[cl=={},0,First[cl]]]; Array[apr,100] (* _Harvey P. Dale_, Jun 01 2012 *)

%t b[n_] := Mod[(-5 + 4 n)!!, (-1 + 2 n)^2]; a = Array[b, 82] (* _Fred Daniel Kline_, Oct 04 2018; Thomas Ordowski's formula with adjusted index *)

%o (PARI) a(n) = if (isprime(p=2*n-1), p, 0); \\ _Michel Marcus_, Aug 09 2018

%o (Magma) DoubleFactorial:=func< n | &*[n..2 by -2] >; [ DoubleFactorial(-5 + 4*n) mod (-1 + 2*n)^2: n in [1..90]]; // _Vincenzo Librandi_, Oct 04 2018

%o (Magma) [IsPrime(2*n-1) select 2*n-1 else 0: n in [1..90]]; // _Bruno Berselli_, Oct 05 2018

%Y Cf. A122845.

%K nonn,easy

%O 1,2

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

%E More terms from _David Wasserman_, Jan 25 2005

%E New name using formula from _David Wasserman_, _Joerg Arndt_, Jul 24 2016