def test_factorial(self, number, expected): '''Test our factorial function''' answer = factorial(number) assert answer == expected
def rsum(n): t = factorial( 4 * n) * (1103 + 26390 * n) / (factorial(n)**4 * 396**(4 * n)) return t + rsum(n - 1) if n else t
def sin_series_sum(x, n): """Uses Taylor's expansion to compute sin(x) """ term = (-1)**n / factorial(2*n + 1) * x**(2*n+1) return term + sin_series_sum(x, n-1) if n else term
def rsum(n): """ Caclulating pi using ramadans sum""" t = factorial( 4 * n) * (1103 + 26390 * n) / (factorial(n)**4 * 396**(4 * n)) return t + rsum(n - 1) if n else t
def sin(x): y = (x / 180) * pi() result = y - ((y**3) / factorial(3)) + ((y**5) / factorial(5)) - ( (y**7) / factorial(7)) return result
def my_sin(x, n): sine = 0 for i in range(n): sine += ((-1)**i) * (x**(2. * i + 1)) / (factorial(2. * i + 1.)) return sine