From 52c58ec87f44789a76b374bddb19a98b589f0db5 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 6 Oct 2023 01:13:19 +0800 Subject: [PATCH] Update 70_math.py --- tests/70_math.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/70_math.py b/tests/70_math.py index 0545aabc..4dbcce67 100644 --- a/tests/70_math.py +++ b/tests/70_math.py @@ -25,4 +25,34 @@ assert floor(-1.2) == -2 assert ceil(1.2) == 2 assert ceil(-1.2) == -1 -assert isclose(sqrt(4), 2.0) \ No newline at end of file +assert isclose(sqrt(4), 2.0) + +import math + +# test fsum +assert math.fsum([0.1] * 10) == 1.0 + +# test gcd +assert math.gcd(10, 5) == 5 +assert math.gcd(10, 6) == 2 +assert math.gcd(10, 7) == 1 +assert math.gcd(10, 10) == 10 +assert math.gcd(-10, 10) == 10 + +# test modf +x, y = math.modf(1.5) +assert isclose(x, 0.5) +assert isclose(y, 1.0) + +x, y = math.modf(-1.5) +assert isclose(x, -0.5) +assert isclose(y, -1.0) + +# test factorial +assert math.factorial(0) == 1 +assert math.factorial(1) == 1 +assert math.factorial(2) == 2 +assert math.factorial(3) == 6 +assert math.factorial(4) == 24 +assert math.factorial(5) == 120 +