def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
def sin(x):
OddNumber = 3
counter = 1
NumberOfTerms = 80
while counter < NumberOfTerms:
x -= (x**OddNumber)/(factorial(OddNumber))
OddNumber += 2
counter += 1
x += (x**OddNumber)/(factorial(OddNumber))
OddNumber += 2
counter += 1
return x
theta = float(input("input angle in degrees: "))
theta = float((theta*math.pi/180))
print(sin(theta))
This is the code I'm using to try to find the approximation of sin of an angle x. I want to increase the variable NumberOfTerms to increase the precision but when I do i get this error
OverflowError: int too large to convert to float
How can I get around this? Is there a way to get around this?