fork download
  1. with Ada.Text_IO; use Ada.Text_IO;
  2. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  3.  
  4. procedure Program is
  5.  
  6. procedure GCD (U, V : in Integer; X : out Integer) is
  7. Y, T, Z : Integer;
  8. begin
  9. Z := U;
  10. Y := V;
  11. loop
  12. exit when Y = 0;
  13. T := Y;
  14. Y := Z mod Y;
  15. Z := T;
  16. end loop;
  17. X := Z;
  18. end GCD;
  19.  
  20. GCD_Ans : Integer;
  21.  
  22. begin
  23. GCD (8, 18, GCD_Ans);
  24. Put ("gcd(8, 18) = ");
  25. Put (GCD_Ans);
  26. New_Line;
  27. end Program;
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
gcd(8, 18) =           2