about summary refs log tree commit diff
path: root/others/volume1/003.scm
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-19 22:28:52 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-19 22:28:52 +0700
commitd40c9b81db3caff8ecca79df92241bc0c28a468c (patch)
tree41985e48e9da1fbfb65af8105bfa0304744320bd /others/volume1/003.scm
parenta53c4128c29f98b5fdfd9b0e13a3bbe094d975ec (diff)
downloadcp-d40c9b81db3caff8ecca79df92241bc0c28a468c.tar.gz
Translate easy programs to Scheme
Diffstat (limited to 'others/volume1/003.scm')
-rw-r--r--others/volume1/003.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/others/volume1/003.scm b/others/volume1/003.scm
new file mode 100644
index 0000000..21431e7
--- /dev/null
+++ b/others/volume1/003.scm
@@ -0,0 +1,8 @@
+(define n (read))
+(display (string-length (number->string n)))
+(display " ")
+(define (digitsum n) (if (> n 0)
+                         (+ (modulo n 10) (digitsum (quotient n 10)))
+                         0))
+(display (digitsum n))
+(newline)