From 6767e8a3f3e0cb20fc3ef3903655219edf3ba532 Mon Sep 17 00:00:00 2001 From: fdai7764 Date: Sun, 28 Jan 2024 12:52:40 +0100 Subject: [PATCH] refactoring: Made the piApproxLeibniz function use the already implemented functions for basic addition, multiplication and division --- src/main/py/trigonometry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index c2e6635..b33c8bb 100644 --- a/src/main/py/trigonometry.py +++ b/src/main/py/trigonometry.py @@ -1,15 +1,15 @@ import math from src.main.py.logarithmic_and_expo_and_root_calculations import potentiate - +from src.main.py.primitive_calculations import * def pi_approx_leibniz(precision): if precision < 0: return -1 result = 0 for i in range(precision): num = potentiate(-1, i) - denom = 2*i + 1 - result += num/denom - return result * 4 + denom = add(1, multiply(2,i)) + result = add(result, divide(num, denom)) + return multiply(result, 4) def rad2deg(radNumber): return (radNumber * 180) / math.pi \ No newline at end of file