cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A089306 Smallest prime of the form n + (n+1)+ (n+2)+...+(n+k), or 0 if no such prime exists.

This page as a plain text file.
%I A089306 #18 Feb 21 2024 01:45:33
%S A089306 3,2,3,0,5,13,7,17,19,0,11,0,13,29,31,0,17,37,19,41,43,0,23,0,0,53,0,
%T A089306 0,29,61,31,0,67,0,71,73,37,0,79,0,41,0,43,89,0,0,47,97,0,101,103,0,
%U A089306 53,109,0,113,0,0,59,0,61,0,127,0,131,0,67,137,139,0,71,0,73,149,151,0,0
%N A089306 Smallest prime of the form n + (n+1)+ (n+2)+...+(n+k), or 0 if no such prime exists.
%C A089306 If n is prime a(n) = n, If n is not a prime but 2n+1 is a prime then a(n) = 2n+1 else a(n) = 0, as the difference of two triangular numbers is composite if the indices differ by more than 2. r(r+1)/2 - s(s+1)/2 is composite if r-s >2.
%H A089306 R. J. Mathar, <a href="/A089306/b089306.txt">Table of n, a(n) for n = 1..1000</a>
%p A089306 A089306 := proc(n)
%p A089306     local k;
%p A089306     if not isprime(n) and not isprime(2*n+1) then
%p A089306         return 0 ;
%p A089306     end if;
%p A089306     for k from 0 do
%p A089306         p := (k+1)*(k+2*n)/2 ;
%p A089306         if isprime(p) then
%p A089306             return p;
%p A089306         end if;
%p A089306     end do:
%p A089306 end proc; # _R. J. Mathar_, Jun 06 2013
%t A089306 a[n_] := Module[{k}, If[!PrimeQ[n] && !PrimeQ[2n+1], Return[0]]; For[k = 0, True, k++, p = (k+1)(k+2n)/2; If[PrimeQ[p], Return[p]]]];
%t A089306 Array[a, 100] (* _Jean-François Alcover_, Mar 25 2020, after _R. J. Mathar_ *)
%K A089306 nonn
%O A089306 1,1
%A A089306 _Amarnath Murthy_, Nov 01 2003
%E A089306 More terms from _David Wasserman_, Sep 09 2005