- Select[Tuples[Range@20,{4}],Mod[#[[2]]+#[[3]],#[[1]]]==0&&Mod[#[[3]]+#[[4]],#[[2]]]==0&&Mod[#[[4]]+#[[1]],#[[3]]]==0&&Mod[#[[1]]+#[[2]],#[[4]]]==0&&GCD@@#==1&]
复制代码
{{1,1,1,1},{1,1,1,2},{1,1,2,1},{1,1,3,2},{1,2,1,1},{1,2,1,3},{1,3,1,2},{1,3,2,1},{1,3,5,4},{1,4,3,5},{1,5,2,3},{1,5,3,2},{2,1,1,1},{2,1,1,3},{2,1,3,1},{2,1,5,3},{2,3,1,5},{2,3,7,5},{2,5,3,7},{3,1,2,1},{3,1,5,2},{3,2,1,1},{3,2,1,5},{3,4,5,7},{3,5,1,4},{3,5,4,1},{3,7,2,5},{3,7,5,2},{4,1,3,5},{4,3,5,1},{4,5,7,3},{5,1,4,3},{5,2,3,1},{5,2,3,7},{5,3,2,1},{5,3,7,2},{5,4,1,3},{5,7,3,4},{7,2,5,3},{7,3,4,5},{7,5,2,3}}
穷举1-20的所有组合,满足条件的四元组最大的数字是7,或许可以从这里下手 |