From 514e17f69c4963fefc07e151f1c2222fc1282394 Mon Sep 17 00:00:00 2001 From: eric-hu Date: Sun, 12 Aug 2012 20:04:31 -0700 Subject: [PATCH] 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. --- src/koans/13_recursion.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/koans/13_recursion.clj b/src/koans/13_recursion.clj index 53a9265..7575b9b 100644 --- a/src/koans/13_recursion.clj +++ b/src/koans/13_recursion.clj @@ -16,6 +16,9 @@ (defn factorial [n] __) +(defn factorial-bigint [n] + __) + (meditations "Recursion ends with a base case" (= true (is-even? 0)) @@ -45,7 +48,7 @@ (= 24 (factorial 4)) "You can even deal with very large numbers" - (< 1000000000000000000000000N (factorial 1000N)) + (< 1000000000000000000000000N (factorial-bigint 1000N)) "But what happens when the machine limits you?" - (< 1000000000000000000000000N (factorial 100003N))) + (< 1000000000000000000000000N (factorial-bigint 100003N)))