Program to Calculate e ^ x by Recursion ( using Taylor Series ) | Recursive Function global variables p and f ; Termination condition ; Recursive call ; Update the power of x ; Factorial ; Driver code
p = 1.0 NEW_LINE f = 1.0 NEW_LINE def e ( x , n ) : NEW_LINE INDENT global p , f NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT r = e ( x , n - 1 ) NEW_LINE p = p * x NEW_LINE f = f * n NEW_LINE return ( r + p / f ) NEW_LINE DEDENT x = 4 NEW_LINE n = 15 NEW_LINE print ( e ( x , n ) ) NEW_LINE