From 93b53a5354620d94b128008d0b17670cc87c92f5 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 21 Mar 2024 12:51:02 +0100 Subject: Added lcm --- samples/rosetta/hailstone.bruijn | 2 +- samples/rosetta/least_common_multiple.bruijn | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 samples/rosetta/least_common_multiple.bruijn (limited to 'samples/rosetta') diff --git a/samples/rosetta/hailstone.bruijn b/samples/rosetta/hailstone.bruijn index 46cf8a2..d98c235 100644 --- a/samples/rosetta/hailstone.bruijn +++ b/samples/rosetta/hailstone.bruijn @@ -16,6 +16,6 @@ seq-27 hailstone (+27b) :test (take (+4) <~>seq-27) ((+1b) : ((+2b) : ((+4b) : {}(+8b)))) all-below-100000 [0 : ∀(hailstone 0)] <$> seq - seq take (+1000) (iterate ++‣ (+1b)) + seq take (+99999) (iterate ++‣ (+1b)) main [head (max-by (M.compare ⋔ tail) all-below-100000)] diff --git a/samples/rosetta/least_common_multiple.bruijn b/samples/rosetta/least_common_multiple.bruijn new file mode 100644 index 0000000..9a6c08e --- /dev/null +++ b/samples/rosetta/least_common_multiple.bruijn @@ -0,0 +1,8 @@ +:import std/Math . + +lcm [[=?1 1 (=?0 0 |(1 / (gcd 1 0) ⋅ 0))]] + +:test ((lcm (+12) (+18)) =? (+36)) ([[1]]) +:test ((lcm (+42) (+25)) =? (+1050)) ([[1]]) + +main [[0]] -- cgit v1.2.3