Find the sum of the first N Centered Decagonal Numbers | Java program to find the sum of the first N centred decagonal number ; Function to find the N - th centred decagonal number ; Formula to calculate nth centered_decagonal number & return it into main function . ; Function to find the sum of the first N centered decagonal numbers ; Variable to store the sum ; Iterating through the range ; Driver code ; Display first Nth centered_decagonal number
class GFG { static int Centered_decagonal_num ( int n ) { return ( 5 * n * n - 5 * n + 1 ) ; } static int sum_Centered_decagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_decagonal_num ( i ) ; } return summ ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( sum_Centered_decagonal_num ( n ) ) ; } }