Update src/koans/13_recursion.clj
Made a separate function for the factorial function applied to bigints. The reason for this is that after successfully implementing a solution for the "Simple things may appear simple." koan and the other non-bigint factorial koans, the `script/run` application throws a java.lang.StackOverflowError. Instead, it should signal to the user that he's working on the next koan.
This commit is contained in:
parent
626f97de8f
commit
514e17f69c
1 changed files with 5 additions and 2 deletions
|
|
@ -16,6 +16,9 @@
|
||||||
(defn factorial [n]
|
(defn factorial [n]
|
||||||
__)
|
__)
|
||||||
|
|
||||||
|
(defn factorial-bigint [n]
|
||||||
|
__)
|
||||||
|
|
||||||
(meditations
|
(meditations
|
||||||
"Recursion ends with a base case"
|
"Recursion ends with a base case"
|
||||||
(= true (is-even? 0))
|
(= true (is-even? 0))
|
||||||
|
|
@ -45,7 +48,7 @@
|
||||||
(= 24 (factorial 4))
|
(= 24 (factorial 4))
|
||||||
|
|
||||||
"You can even deal with very large numbers"
|
"You can even deal with very large numbers"
|
||||||
(< 1000000000000000000000000N (factorial 1000N))
|
(< 1000000000000000000000000N (factorial-bigint 1000N))
|
||||||
|
|
||||||
"But what happens when the machine limits you?"
|
"But what happens when the machine limits you?"
|
||||||
(< 1000000000000000000000000N (factorial 100003N)))
|
(< 1000000000000000000000000N (factorial-bigint 100003N)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue