aboutsummaryrefslogtreecommitdiff
path: root/challenge-112
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-05-11 20:39:02 +0200
committerAbigail <abigail@abigail.be>2021-05-11 20:39:02 +0200
commit028c211ace8aaa8e026dfe9f0a6ca979f4901c07 (patch)
tree3a73bab7e86f93acc6bddfa256e7cb1e08369167 /challenge-112
parent962c17a7075cedbd4b75e894cd40e06ebb33da69 (diff)
downloadperlweeklychallenge-club-028c211ace8aaa8e026dfe9f0a6ca979f4901c07.tar.gz
perlweeklychallenge-club-028c211ace8aaa8e026dfe9f0a6ca979f4901c07.tar.bz2
perlweeklychallenge-club-028c211ace8aaa8e026dfe9f0a6ca979f4901c07.zip
Scheme solution for week 112, part 2
Diffstat (limited to 'challenge-112')
-rw-r--r--challenge-112/abigail/README.md3
-rw-r--r--challenge-112/abigail/scheme/ch-2.scm25
2 files changed, 27 insertions, 1 deletions
diff --git a/challenge-112/abigail/README.md b/challenge-112/abigail/README.md
index 6fae38d608..38877538e6 100644
--- a/challenge-112/abigail/README.md
+++ b/challenge-112/abigail/README.md
@@ -64,6 +64,7 @@ This is just finding the `$n + 1` Fibonacci number.
* [Perl](perl/ch-2.pl)
* [Pascal](pascal/ch-2.p)
* [Python](python/ch-2.py)
-* [Ruby](ruby/ch-1.rb)
+* [Ruby](ruby/ch-2.rb)
+* [Scheme](scheme/ch-2.scm)
### Blog
diff --git a/challenge-112/abigail/scheme/ch-2.scm b/challenge-112/abigail/scheme/ch-2.scm
new file mode 100644
index 0000000000..1223c8719b
--- /dev/null
+++ b/challenge-112/abigail/scheme/ch-2.scm
@@ -0,0 +1,25 @@
+;;;
+;;; See ../README.md
+;;;
+
+;;;
+;;; Run as: guile --no-auto-compile ch-2.scm
+;;;
+
+(use-modules (ice-9 format))
+
+(define sqrt5 (sqrt 5))
+(define phi (/ (+ 1 sqrt5) 2))
+
+(define (stairs)
+ (define n (read))
+ (if (not (eof-object? n))
+ (begin
+ (format #t "~d\n"
+ (inexact->exact (round (/ (expt phi (+ n 1)) sqrt5))))
+ (stairs)
+ )
+ )
+)
+
+(stairs)