tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
9
Task/Nth-root/Common-Lisp/nth-root-1.lisp
Normal file
9
Task/Nth-root/Common-Lisp/nth-root-1.lisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(defun nth-root (n a &optional (epsilon .0001) (guess (1- n)))
|
||||
(assert (and (> n 1) (> a 0)))
|
||||
(flet ((next (x)
|
||||
(/ (+ (* (1- n) x)
|
||||
(/ a (expt x (1- n))))
|
||||
n)))
|
||||
(do* ((xi guess xi+1)
|
||||
(xi+1 (next xi) (next xi)))
|
||||
((< (abs (- xi+1 xi)) epsilon) xi+1))))
|
||||
4
Task/Nth-root/Common-Lisp/nth-root-2.lisp
Normal file
4
Task/Nth-root/Common-Lisp/nth-root-2.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(let* ((r (nth-root 3 10))
|
||||
(rf (coerce r 'float)))
|
||||
(print (* r r r ))
|
||||
(print (* rf rf rf)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue