(MAGMAMagma) 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
(MAGMAMagma) 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