From f128e3939d1b547a3a408529b8698d08ebcaf6d7 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Sun, 25 Jul 2021 17:54:07 +0900 Subject: consecutive-fibonacci-numbers-are-coprime: ガードを追加 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consecutive-fibonacci-numbers-are-coprime.lisp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'consecutive-fibonacci-numbers-are-coprime.lisp') 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)) -- cgit v1.2.3