Program for sum of cosh ( x ) series upto Nth term | Java program for the sum of cosh ( x ) series ; function to return the factorial of a number ; function to return the sum of the series ; Driver code
import java . util . * ; class GFG { static int fact ( int n ) { int i = 1 , fac = 1 ; for ( i = 1 ; i <= n ; i ++ ) fac = fac * i ; return fac ; } static double log_Expansion ( double x , int n ) { double sum = 0 ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum = sum + Math . pow ( x , 2 * i ) / fact ( 2 * i ) ; } return sum ; } public static void main ( String [ ] args ) { double x = 1 ; int n = 10 ; System . out . println ( log_Expansion ( x , n ) ) ; } }