Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 0.61 KB | None | 0 0
  1. note
  2.     description : "project application root class"
  3.     date        : "$Date$"
  4.     revision    : "$Revision$"
  5.  
  6.  
  7.  
  8. class
  9.     APPLICATION
  10.  
  11. inherit
  12.     ARGUMENTS
  13.  
  14. create
  15.     make
  16.  
  17. feature {NONE} -- Initialization
  18.  
  19.  
  20.     gcd(x , y :INTEGER):INTEGER
  21.         local
  22.             n,m :INTEGER
  23.         do
  24.             from
  25.                 m := x
  26.                 n := y
  27.             invariant
  28.                 gcd(x , y) = gcd(n , m)
  29.  
  30.  
  31.             until
  32.                 m = n
  33.  
  34.             loop
  35.                 if(m > n) then
  36.                     m := m - n
  37.                 else n := n - m
  38.                 end
  39.             variant
  40.                         n + m
  41.             end
  42.             Result := m
  43.         end
  44.     make
  45.             -- Run application.
  46.         do
  47.             a := 24
  48.             b := 9
  49.             print(gcd(a , b));
  50.  
  51.         end
  52.     a,b:INTEGER
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement