Eugeniusz Jakubas
programy źródłowe w Pascalu

Stąd można pobrać teksty źródłowe poniższych 57 programów w Pascalu pr-pascal.zip - 34 kB

43. Twierdzenie o resztach

program Tw_1a_o_resztach;
uses crt;
var a,b,c,x,y:longInt;
begin
  clrScr;
  writeLn('Tw.1a.     (a+b) mod c = ((a mod c)+(b mod c)) mod c');
  writeLn('-----------------------------------------------------');
  randomize;
  a:=random(40);
  b:=random(30);
  c:=random(20)+1;
  x:=a mod c;
  y:=b mod c;
  textColor(lightGray);
  writeLn('Przyklad:  a = ',a,',    b = ',b,',    c = ',c,',');
  writeLn;
  writeLn(' L = (',a,'+',b,') mod ',c,' = ');
  writeLn('   = ',a+b,' mod ',c,' = ');
  textColor(lightRed);
  writeLn('   = ',(a+b) mod c);
  textColor(lightGray);
  writeLn(' P = ((',a,' mod ',c,')+(',b,' mod ',c,')) mod ',c,' = ');
  writeLn('   = (',x,'+',y,') mod ',c,' = ');
  writeLn('   = ',x+y,' mod ',c,' = ');
  textColor(lightRed);
  writeLn('   = ',(x+y) mod c);
  textColor(lightGray);
  writeLn(' L = P');
  readLn;
end.