text: Program to Calculate e ^ x by Recursion ( using Taylor Series ) | C implementation of the approach ; Recursive Function with static variables p and f ; Termination condition ; Recursive call ; Update the power of x ; Factorial ; Driver code
code: #include <stdio.h> NEW_LINE double e ( int x , int n ) { static double p = 1 , f = 1 ; double r ; if ( n == 0 ) return 1 ; r = e ( x , n - 1 ) ; p = p * x ; f = f * n ; return ( r + p / f ) ; } int main ( ) { int x = 4 , n = 15 ; printf ( " % lf ▁ STRNEWLINE " , e ( x , n ) ) ; return 0 ; }