Skip to content

Commit f8b7f8a

Browse files
committed
feat(tests): adding Rosetta Code solution for Calculating the value of e
1 parent 75d4a37 commit f8b7f8a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(import std.Range :range)
2+
(import std.List)
3+
4+
(let fact (fun (n acc) {
5+
(if (> n 0)
6+
(fact (- n 1) (* acc n))
7+
acc) }))
8+
9+
(let r (range 1 18))
10+
(let p
11+
(list:sum
12+
(list:map
13+
(list:reverse (r.asList))
14+
(fun (n)
15+
(/ 1 (fact n 1)) ))))
16+
17+
(import std.Math :abs)
18+
19+
(let my_e (+ p 1))
20+
(assert (< (abs (- my_e math:e)) (toNumber "1e-15")) "computed e is near the math:e")

0 commit comments

Comments
 (0)