aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--entries/jyoo980/vintage-htdp/fib.rkt17
-rw-r--r--people.json5
2 files changed, 22 insertions, 0 deletions
diff --git a/entries/jyoo980/vintage-htdp/fib.rkt b/entries/jyoo980/vintage-htdp/fib.rkt
new file mode 100644
index 0000000..697c17b
--- /dev/null
+++ b/entries/jyoo980/vintage-htdp/fib.rkt
@@ -0,0 +1,17 @@
+;; Natural -> Natural
+;; given n, produce the nth fibonacci number
+(check-expect (fib 0) 0)
+(check-expect (fib 1) 1)
+(check-expect (fib 2) 1)
+(check-expect (fib 7) 13)
+
+; (define (fib n) 0) ; stub
+
+;<template from Natural>
+(define (fib n)
+ (cond
+ [(zero? n) 0]
+ [else
+ (if (= n 1)
+ 1
+ (+ (fib (sub1 n)) (fib (- n 2))))]))
diff --git a/people.json b/people.json
index 2658904..ecb28dd 100644
--- a/people.json
+++ b/people.json
@@ -71,7 +71,12 @@
{
"name": "scala",
"link": "./entries/jyoo980/scala/Fib.scala"
+ },
+ {
+ "name": "vintage-htdp",
+ "link": "./entries/jyoo980/vintage-htdp/fib.rkt"
}
+
]
},
{