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.

A174960 Smallest prime p such that p + n*(n+1)/2 is prime, or 0 if no such prime exists.

Original entry on oeis.org

2, 2, 2, 5, 3, 2, 2, 3, 5, 2, 0, 5, 5, 0, 2, 7, 3, 0, 2, 3, 13, 2, 0, 5, 7, 0, 2, 5, 3, 0, 2, 3, 13, 2, 0, 11, 7, 0, 2, 7, 3, 2, 0, 7, 7, 0, 0, 23, 5, 0, 2, 41, 3, 2, 2, 3, 5, 0, 0, 7, 17, 0, 0, 11, 3, 0, 2, 3, 5, 2, 0, 23, 5, 0, 2, 7, 13, 0, 2, 3, 11, 2, 0, 5, 11, 0, 0, 5, 3, 2, 0, 31, 5, 2, 0, 7, 7, 0, 0
Offset: 0

Views

Author

Michel Lagneau, Apr 02 2010

Keywords

Comments

n(n+1)/2 = A000217(n).
If n(n+1)/2 is odd, m+n(n+1)/2 can be prime only for m = 2, since otherwise m+n(n+1)/2 is divisible by 2. Hence a(n) = 0 if n(n+1)/2 is odd and 2+n(n+1)/2 is not prime.
For n > 0 also smallest m such that all eigenvalues of the n X n matrix M_m,n are prime, where M_m,n(j,k) = j for j <> k, M_m,n(j,k) = m+j for j = k.
The eigenvalues of M_m,n are m+n(n+1)/2, and m with the multiplicity n-1; cf. reference for proof. Thus all eigenvalues can be prime only if m is prime.

Examples

			(in Maple notation)
For n = 1 and m = 2, eigenvals(matrix(1,1, [[3]])) = {3}, so a(1) = 2.
For n = 2 and m = 2, eigenvals(matrix(2,2, [[3,1],[2,4]]) = {2,5} so a(2) = 2.
For n = 3 and m = 2, eigenvals(matrix(3,3, [[3,1,1],[2,4,2],[3,3,5]])) = {2,2,8} and 8 is not prime; for m = 3, eigenvals(matrix(3,3, [[4,1,1],[2,5,2],[3,3,6]])) = {3,3,9} and 9 is not prime; for m = 5, eigenvals(matrix(3,3, [[6,1,1],[2,7,2],[3,3,8]])) = {5,5,11} and 11 is prime, so a(3) = 5;
		

References

  • J.-M. Monier, Algebre et geometrie, exercices corriges. Dunod, 1997, p. 78.

Crossrefs

Cf. A000217 (triangular numbers), A174962.

Programs

  • Magma
    SmallestP:=function(n) for p in PrimesUpTo(1000) do if IsPrime(p + n*(n+1) div 2) then return p; end if; end for; return 0; end function; [SmallestP(n): n in [0..100]]; // Klaus Brockhaus, Apr 10 2010
    
  • Magma
    SmallestQ:=function(n) for m in PrimesUpTo(1000) do E:=Eigenvalues(Matrix([&cat[ [j ne k select j else m+j]: k in [1..n]]: j in [1..n] ])); if forall(t){x: x in E | IsPrime(x[1])} then return m; end if; end for; return 0; end function; [2] cat [SmallestQ(n): n in [1..100]]; // Klaus Brockhaus, Apr 10 2010
  • Maple
    with(numtheory):for n from 1 to 200 do:nn:=1:for k from 2 to 1000 do: x:=k + n*(n+1)/2:if (type(x,prime)=true)and(type(k,prime)=true)and nn=1 then print(k):nn:=2:else fi:od:od:
  • Mathematica
    a[n_] := (p = 2; q = n*(n+1)/2; While[p > 0, If[ PrimeQ[p+q], Break[], p = If[ OddQ[q], 0, NextPrime[p]]]]; p); Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Nov 03 2011 *)

Extensions

Edited and corrected by Klaus Brockhaus, Apr 10 2010