Function IsSimple(n: Word): Boolean; Var T: Word; Begin IsSimple := True; T := 2; While (T < n) Do Begin If (n mod T = 0) Then Begin IsSimple := False; Break; End Else Inc(T); End; End;
Begin ClrScr; Repeat Write('Введите N: '); ReadLn(k); Until (n > 0); Writeln('Ищем на промежутке [',k,';',k*2,']'); x := k; Repeat If (IsSimple(x) and IsSimple(2+x)) then Begin Write('Найдена пара чисел-близнецов: '); Writeln(x+2, ' - ', x, ' = 2'); End; Inc(x); Until (x = 2 * k); ReadKey; End.