From 052e78bf2e55d1fa356000c7634a2107c0a36bd4 Mon Sep 17 00:00:00 2001 From: r4 Date: Wed, 22 Dec 2021 17:40:54 +0100 Subject: [PATCH] add pi example --- calculate_pi.script | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 calculate_pi.script diff --git a/calculate_pi.script b/calculate_pi.script new file mode 100644 index 0000000..2f9ed6e --- /dev/null +++ b/calculate_pi.script @@ -0,0 +1,13 @@ +sum := 0.0 +k := 0 + +iterations := 100 + +while k - iterations { + // This is only so messy because I haven't implemented parentheses yet so I + // have to wrap everything into functions instead. + sum = sum + 1.0 / pow(16.0, float(k)) * float(4.0 / float(8.0 * float(k) + 1.0) - 2.0 / float(8.0 * float(k) + 4.0) - 1.0 / float(8.0 * float(k) + 5.0) - 1.0 / float(8.0 * float(k) + 6.0)) + k = k + 1 +} + +print(sum)