Advertisement
MadCortez

Untitled

Dec 8th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.75 KB | None | 0 0
  1. program rabotaet;
  2.  
  3. var
  4.    i, n, coren, n1, n2, n3, n4: integer;
  5.    Flag, FlagProstoe: Boolean;
  6.    s: String;
  7.  
  8. begin
  9.    for n := 1000 to 9999 do
  10.    begin
  11.       n1 := n div 1000;
  12.       n2 := n div 100 mod 10;
  13.       n3 := n div 10 mod 10;
  14.       n4 := n mod 10;
  15.       if (n1 = n2) and (n3 = n4) then
  16.       begin
  17.          Flag := False;
  18.          coren := trunc(sqrt(n));
  19.          for i := 2 to coren do
  20.             if n mod i = 0 then
  21.             begin
  22.                Flag := True;
  23.                break;
  24.             end;
  25.          if not(Flag) then
  26.          begin
  27.             Writeln('Prostoe ', n);
  28.             FlagProstoe := True;
  29.          end;
  30.       end;
  31.    end;
  32.    if not(FlagProstoe) then
  33.       Writeln('No solution');
  34.    Readln;
  35. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement