// PascalABC.NET 3.3, сборка 1555 от 21.10.2017
// Внимание! Если программа не работает, обновите версию!
begin
var (p,q,s):=(1,2,0);
var k:=0;
Write('(1,5) ');
for var i:=3 to 1000 do begin
var (flag,j,r):=(True,2,Round(Sqrt(i)));
while flag and (j<=r) do<br> if i mod j = 0 then flag:=false
else j+=1;
if flag then begin
(p,q,s):=(q,s,i);
if q-p=4 then Write('(',p,',',q,') ')
else
if s-p=4 then Write('(',p,',',s,') ')
end
end
end.
Результат
(1,5) (3,7) (7,11) (13,17) (19,23) (37,41) (43,47) (67,71) (79,83) (97,101) (103,107) (109,113) (127,131) (163,167) (193,197) (223,227) (229,233) (277,281) (307,311) (313,317) (349,353) (379,383) (397,401) (439,443) (457,461) (463,467) (487,491) (499,503) (613,617) (643,647) (673,677) (739,743) (757,761) (769,773) (823,827) (853,857) (859,863) (877,881) (883,887) (907,911) (937,941) (967,971)