shoodymon

Untitled

Mar 8th, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.51 KB | None | 0 0
  1. program hw10;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8.   System.SysUtils, Math;
  9.  
  10. var
  11.     i,temp,digits,Sum:Integer;
  12.  
  13. begin
  14.  
  15.   for i := 10 to 9999 do
  16.   begin
  17.     digits := 0;
  18.     temp := i;
  19.     while temp > 0 do
  20.     begin
  21.       temp := temp div 10;
  22.       Inc(digits);
  23.     end;
  24.  
  25.     temp := i;
  26.     Sum := 0;
  27.     while temp > 0 do
  28.     begin
  29.       Sum := Sum + Round(Power(temp mod 10,digits));
  30.       temp := temp div 10;
  31.     end;
  32.     if i = Sum then
  33.     writeln (i);
  34.   end;
  35.  
  36.    Readln;
  37. end.
Advertisement
Add Comment
Please, Sign In to add comment