Consider the following code in Common Lisp:
(defun range (max &key (min 0) (step 1))
(loop for n from min below max by step
collect n))
(reduce
This gives the expected value of the bonus 60! Namely
8320987112741390144276341183223364380754172606361245952449277696409600000000000000
However, the following code, which does not include any restraining floating point operations that I see, produces a floating point response:
(defun fact (n)
(if (= 0 n)
1
(* n (fact (- n 1)))))
(fact 60)
8.32098711274139e+81
Questions: "why?" and "how can I write a simple, recursive factin SBCL (Steel-Bank Common Lisp) that produces a bignum result?"
source
share