From d40c9b81db3caff8ecca79df92241bc0c28a468c Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 19 Feb 2017 22:28:52 +0700 Subject: Translate easy programs to Scheme --- others/mHoang/decor.scm | 2 ++ others/mHoang/pfactor.scm | 9 +++++++++ others/mHoang/triangle.scm | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 others/mHoang/decor.scm create mode 100644 others/mHoang/pfactor.scm create mode 100644 others/mHoang/triangle.scm (limited to 'others/mHoang') diff --git a/others/mHoang/decor.scm b/others/mHoang/decor.scm new file mode 100644 index 0000000..1b4cea2 --- /dev/null +++ b/others/mHoang/decor.scm @@ -0,0 +1,2 @@ +(display (exact-integer-sqrt (read))) +(newline) diff --git a/others/mHoang/pfactor.scm b/others/mHoang/pfactor.scm new file mode 100644 index 0000000..4e3bd17 --- /dev/null +++ b/others/mHoang/pfactor.scm @@ -0,0 +1,9 @@ +(define (div dividend divisor) + (if (= (remainder dividend divisor) 0) + (div (/ dividend divisor) divisor) + dividend)) +(display (let* ((n (read)) (s (exact-integer-sqrt n))) + (do ((i 2 (+ i 1))) + ((or (= (div n i) 1) (> i s)) (if (> i s) n i)) + (set! n (div n i))))) +(newline) diff --git a/others/mHoang/triangle.scm b/others/mHoang/triangle.scm new file mode 100644 index 0000000..33a154b --- /dev/null +++ b/others/mHoang/triangle.scm @@ -0,0 +1,5 @@ +(define (angel-90 a b c) + ((lambda (x) (if (= x 0) 0 (/ x (abs x)))) (+ (* a a) (* b b) (- (* c c))))) +(display (let ((a (read)) (b (read)) (c (read))) + (modulo (* (angel-90 a b c) (angel-90 b c a) (angel-90 c a b)) 3))) +(newline) -- cgit 1.4.1