- Clear["Global`*"];(*Clear all variables*)
- aaa=Table[Prime[k],{k,2,1000}];(*素数表,从第2个到第1000个*)
- Do[ lst={0,1,2,3,4,5,6}*d;(*公差*)
- If[Union@PrimeQ[p1+lst]=={True},(*必须都是素数*)
- Print[{p1,d,p1+lst}](*输出求解结果:第一个素数、公差、所有素数*)
- ],
- {p1,aaa},(*第一个素数必然来自上面的素数表*)
- {d,2,1000,2}](*公差只可能是偶数*)
复制代码
我只会穷举法:假设第一个素数在前1000个素数里面,再假设公差小于1000,然后穷举,找出
求解结果中最小的,那就是得到的结果。
{7,150,{7,157,307,457,607,757,907}}
{47,210,{47,257,467,677,887,1097,1307}}
{179,210,{179,389,599,809,1019,1229,1439}}
{193,420,{193,613,1033,1453,1873,2293,2713}}
{199,210,{199,409,619,829,1039,1249,1459}}
{409,210,{409,619,829,1039,1249,1459,1669}}
{619,210,{619,829,1039,1249,1459,1669,1879}}
{829,210,{829,1039,1249,1459,1669,1879,2089}}
{881,210,{881,1091,1301,1511,1721,1931,2141}}
{1061,840,{1061,1901,2741,3581,4421,5261,6101}}
{1091,210,{1091,1301,1511,1721,1931,2141,2351}}
{1453,210,{1453,1663,1873,2083,2293,2503,2713}}
{1619,420,{1619,2039,2459,2879,3299,3719,4139}}
{1637,630,{1637,2267,2897,3527,4157,4787,5417}}
{1753,840,{1753,2593,3433,4273,5113,5953,6793}}
{2239,420,{2239,2659,3079,3499,3919,4339,4759}}
{2267,630,{2267,2897,3527,4157,4787,5417,6047}}
{2659,420,{2659,3079,3499,3919,4339,4759,5179}}
{3499,210,{3499,3709,3919,4129,4339,4549,4759}}
{3623,840,{3623,4463,5303,6143,6983,7823,8663}}
{3709,210,{3709,3919,4129,4339,4549,4759,4969}}
{3919,210,{3919,4129,4339,4549,4759,4969,5179}}
{4259,420,{4259,4679,5099,5519,5939,6359,6779}}
{4493,840,{4493,5333,6173,7013,7853,8693,9533}}
{5569,630,{5569,6199,6829,7459,8089,8719,9349}}
{5651,840,{5651,6491,7331,8171,9011,9851,10691}}
{5849,420,{5849,6269,6689,7109,7529,7949,8369}}
{6043,840,{6043,6883,7723,8563,9403,10243,11083}}
{6529,420,{6529,6949,7369,7789,8209,8629,9049}}
{6883,840,{6883,7723,8563,9403,10243,11083,11923}}
{7723,840,{7723,8563,9403,10243,11083,11923,12763}}
上面的第一个就是求解结果! |