From 7d19f480637e9e880b98dabfbcf8e885b0a2d3b9 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Tue, 21 Feb 2017 21:09:39 +0700 Subject: Update others/volume1 --- others/volume1/086.scm | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 others/volume1/086.scm (limited to 'others/volume1/086.scm') diff --git a/others/volume1/086.scm b/others/volume1/086.scm new file mode 100644 index 0000000..a45a81d --- /dev/null +++ b/others/volume1/086.scm @@ -0,0 +1,7 @@ +(define (collatz n output) + (if (> n 1) + (if (= (remainder n 2) 0) + (collatz (quotient n 2) (append output '("x 2\n"))) + (collatz (+ (* n 3) 1) (append output '("div 3\n")))) + output)) +(for-each display (reverse (collatz (read) '()))) -- cgit 1.4.1