fork(3) download
  1. program table_euclid_algo;
  2. var
  3. b,a,r,q:array of integer;
  4. i,x,y:integer;
  5. begin
  6. setLength(b,100);
  7. setLength(a,100);
  8. setLength(r,100);
  9. setLength(q,100);
  10. readln(x,y);
  11. a[0]:=1;
  12. b[0]:=0;
  13. r[0]:=x;
  14. q[0]:=0;
  15.  
  16. a[1]:=0;
  17. b[1]:=1;
  18. r[1]:=y;
  19. q[1]:=x div y;
  20. i:=1;
  21. while r[i]<>1 do
  22. begin
  23. i:=i+1;
  24. a[i]:=a[i-2]-q[i-1]*a[i-1];
  25. b[i]:=b[i-2]-q[i-1]*b[i-1];
  26. r[i]:=r[i-2] mod r[i-1];
  27. q[i]:=r[i-1] div r[i];
  28. end;
  29. writeln('the values of x and y are ',a[i],' ',b[i]);
  30. end.
  31.  
stdin
120
23
compilation info
Free Pascal Compiler version 2.2.0 [2009/11/16] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling prog.pas
Linking prog
30 lines compiled, 0.0 sec
stdout
the values of x and y are -9 47