diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2021-07-25 17:54:07 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2021-07-25 17:54:07 +0900 |
commit | f128e3939d1b547a3a408529b8698d08ebcaf6d7 (patch) | |
tree | ffcef06974c9f32f229b01f10f5d358417c9e188 /consecutive-fibonacci-numbers-are-coprime.lisp | |
parent | 0cad8821900e6df09c3e0702ad6f922d697a2d05 (diff) |
consecutive-fibonacci-numbers-are-coprime: ガードを追加
Diffstat (limited to 'consecutive-fibonacci-numbers-are-coprime.lisp')
-rw-r--r-- | consecutive-fibonacci-numbers-are-coprime.lisp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/consecutive-fibonacci-numbers-are-coprime.lisp b/consecutive-fibonacci-numbers-are-coprime.lisp index d80ce43..482eb65 100644 --- a/consecutive-fibonacci-numbers-are-coprime.lisp +++ b/consecutive-fibonacci-numbers-are-coprime.lisp @@ -5,6 +5,7 @@ ;; フィボナッチ関数の定義 (defun fibonacci (n) + (declare (xargs :guard (natp n))) (cond ((zp n) 0) ((equal n 1) 1) @@ -13,7 +14,9 @@ ;; ユークリッドの互除法による最大公約数の定義 (defun gcd$ (n m) - (declare (xargs :measure (+ (nfix m) (nfix n)))) + (declare (xargs :measure (+ (nfix m) (nfix n)) + :guard (and (posp n) + (posp m)))) (cond ((or (not (posp n)) (not (posp m)) |