From ee57979cfaf37aaf1d7c72155a3f65cc02caa286 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 30 Jun 2021 17:20:46 +0200 Subject: first three --- p1.lisp | 10 ++++++++++ p2.lisp | 14 ++++++++++++++ p3.lisp | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 p1.lisp create mode 100644 p2.lisp create mode 100644 p3.lisp diff --git a/p1.lisp b/p1.lisp new file mode 100644 index 0000000..08723e2 --- /dev/null +++ b/p1.lisp @@ -0,0 +1,10 @@ +(setq sum 0) +(loop for i from 0 to 1001 do + (if (eq (mod i 3) 0) + (setq sum (+ sum i)) + (if (eq (mod i 5) 0) + (setq sum (+ sum i)) + ) + ) +) +(print sum) diff --git a/p2.lisp b/p2.lisp new file mode 100644 index 0000000..488a755 --- /dev/null +++ b/p2.lisp @@ -0,0 +1,14 @@ +(setq a (list 1 2)) +(setq l 0) +(loop while (< l 4000000) do + (setq l (apply '+ (last a 2))) + (nconc a (list l)) +) + +(setq s 0) +(loop for i in a do + (if (eq (mod i 2) 0) + (setq s (+ s i)) + ) +) +(print s) diff --git a/p3.lisp b/p3.lisp new file mode 100644 index 0000000..72645fb --- /dev/null +++ b/p3.lisp @@ -0,0 +1,7 @@ +(setq n 13195) + +(dotimes (i n) + (if (eq (mod i n) 0) + (print i) + ) +) -- cgit v1.2.3