Efficient program to calculate e ^ x | Returns approximate value of e ^ x using sum of first n terms of Taylor Series ; initialize sum of series ; Driver Code
< ? php function exponential ( $ n , $ x ) { $ sum = 1.0 ; for ( $ i = $ n - 1 ; $ i > 0 ; -- $ i ) $ sum = 1 + $ x * $ sum / $ i ; return $ sum ; } $ n = 10 ; $ x = 1.0 ; echo ( " e ^ x ▁ = ▁ " . exponential ( $ n , $ x ) ) ; ? >