Skip to content

Commit f276cb2

Browse files
ChrisO345cclauss
andauthored
Update maths/maclaurin_sin.py
Co-authored-by: Christian Clauss <[email protected]>
1 parent 3952724 commit f276cb2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

maths/maclaurin_sin.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ def maclaurin_sin(theta: float, accuracy: int = 30) -> float:
4949
raise ValueError("maclaurin_sin() requires a positive int for accuracy")
5050

5151
theta = float(theta)
52-
5352
div = theta // (2 * pi)
54-
theta = theta - (2 * div * pi)
55-
56-
total = 0
57-
for r in range(accuracy):
58-
total += ((-1) ** r) * ((theta ** (2 * r + 1)) / (factorial(2 * r + 1)))
53+
theta -= 2 * div * pi
54+
return sum(
55+
((-1) ** r) * ((theta ** (2 * r + 1)) / factorial(2 * r + 1))
56+
for r in range(accuracy)
57+
)
5958
return total
6059

6160

0 commit comments

Comments
 (0)