HomeAboutCodePastes
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordieggsy <dieggsy@pm.me>2021-04-12 12:09:48 -0400
committerdieggsy <dieggsy@pm.me>2021-04-12 12:09:48 -0400
commit4004da049efd88133947352d8679f937fdb6abc2 (patch)
treee83f3ccad82374fa765155b50c704848dd365e5f
parent9cceee6691db78dd7756237b0ab6eef915e316d4 (diff)
downloadproject-euler-4004da049efd88133947352d8679f937fdb6abc2.tar.gz
Add p69 solution in CHICKEN
-rwxr-xr-xchicken/p69.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/chicken/p69.scm b/chicken/p69.scm
new file mode 100755
index 0000000..52f4d4b
--- /dev/null
+++ b/chicken/p69.scm
@@ -0,0 +1,22 @@
+#!/usr/bin/chicken-scheme
+;; AUTOCOMPILE: -O3
+
+(import (math number-theory)
+ (chicken fixnum)
+ (chicken flonum)
+ (srfi 1))
+
+(define (p69)
+ (let ((vals (map (lambda (n)
+ (/ (exact->inexact n)
+ (totient n)))
+ (iota #e1e6 1))))
+ (let loop ((vs vals)
+ (m 0.0)
+ (n 1)
+ (i 1))
+ (cond ((null? vs) n)
+ ((fp> (car vs) m) (loop (cdr vs) (car vs) i (fx+ i 1)))
+ (else (loop (cdr vs) m n (fx+ i 1)))))))
+
+(time (print (p69)))