GamerSK

Armstrongove číslo

Feb 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.49 KB | None | 0 0
  1. program armstrongovocislo;
  2. {$APPTYPE CONSOLE}
  3. uses SysUtils;
  4. type cifry=0..9;
  5.      max=0..10000;
  6. var cf:cifry;
  7.     c,i,t:max;
  8. begin
  9.   { TODO -oUser -cConsole Main : Insert code here }
  10.   write('Armstrongove cisla v intervale 1-10000 su: ');
  11.   for i:=1 to 10000 do
  12.     begin
  13.       t:=0;
  14.       c:=i;
  15.       while c<>0 do
  16.         begin
  17.           cf:=c mod 10;
  18.           c:=c div 10;
  19.           t:=t+(cf*cf*cf);
  20.         end;
  21.       if i=t then write(i,', ');
  22.     end;
  23.   readln;
  24. end.
Advertisement
Add Comment
Please, Sign In to add comment