A174960 Smallest prime p such that p + n*(n+1)/2 is prime, or 0 if no such prime exists.
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
Keywords
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.
Links
- K. Brockhaus, Table of n, a(n) for n = 0..10000
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
Comments