Table of Contents
1 Algorithm
1.1 算法的特性
算法除了是一套有限的規則 (Being a finite set of rules) 以外,還有以下的五個特性: css
- 有限性 (Finiteness) :須要在有限的步驟內收斂結束。
- 可定義性 (Definieness) :算法中的每一步驟必要要有精確的定義。
- 輸入 (input) :有 0 或者多數輸入
- 輸出 (output) :有 1 或者多個輸出
- 有效性 (Effectiveness) :算法一般是有效的。
1.2 例子
Figure 1: Euclid's alrogithmjava
Lisp code: git
(defun ea (m n) "Euclid's algorithm" (interactive) (let ((r (% m n))) (if (= r 0) n (ea n r))))