Last change
on this file since 8991 was
8991,
checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size:
582 bytes

Line  

1  ;* Mode: Lisp * 

2  ;;;; Author: Paul Dietz 

3  ;;;; Created: Wed Sep 3 06:57:22 2003 

4  ;;;; Contains: Aux. functions for testing GCD 

5  

6  (inpackage :cltest) 

7  

8  (defun mygcd (x y) 

9  (cond 

10  ((< x 0) 

11  (mygcd ( x) y)) 

12  ((< y 0) 

13  (mygcd x ( y))) 

14  ((<= x y) 

15  (mygcd* x y)) 

16  (t 

17  (mygcd* y x)))) 

18  

19  (defun mygcd* (x y) 

20  ;;; 0 <= x <= y 

21  (loop 

22  (when (zerop x) (return y)) 

23  (psetq x (mod y x) 

24  y x))) 

25  

26  (defun mylcm (x y) 

27  (when (< x 0) (setf x ( x))) 

28  (when (< y 0) (setf y ( y))) 

29  (if (or (= x 0) (= y 0)) 

30  0 

31  (/ (* x y) (mygcd x y)))) 

32  

33  

34  

Note: See
TracBrowser
for help on using the repository browser.