diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2021-08-15 01:37:13 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2021-08-15 01:37:13 +0900 |
commit | f39b321a0072a1e458d096b7feaddb34fa7a22e2 (patch) | |
tree | 5d66730bb0c0bd4619bb7ba3a10d40830d0ce51a | |
parent | 4ada0d21de63a954c17d0b9ee4002be7fb7e22ab (diff) |
consecutive-fibonacci-numbers-are-coprime: Refactor gcd$ function.
-rw-r--r-- | consecutive-fibonacci-numbers-are-coprime.lisp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/consecutive-fibonacci-numbers-are-coprime.lisp b/consecutive-fibonacci-numbers-are-coprime.lisp index e9bc9e2..1700e8e 100644 --- a/consecutive-fibonacci-numbers-are-coprime.lisp +++ b/consecutive-fibonacci-numbers-are-coprime.lisp @@ -17,13 +17,13 @@ (declare (xargs :measure (+ (nfix m) (nfix n)) :guard (and (posp n) (posp m)))) - (cond - ((or (not (posp n)) - (not (posp m)) - (= (nfix n) (nfix m))) - n) - ((< n m) (gcd$ (- m n) n)) - (t (gcd$ (- n m) m)))) + (if (and (posp n) (posp m)) + (cond + ((= (nfix n) (nfix m)) + n) + ((< n m) (gcd$ (- m n) n)) + (t (gcd$ (- n m) m))) + 0)) ;; gcd$ の結果は正の整数である (defthm posp-gcd$ |