Find the sum of the first Nth Centered Hexadecagonal Number | Java program to find the sum of the first N centred hexadecagonal numbers ; Centered_Hexadecagonal number function ; Formula to calculate nth Centered_Hexadecagonal number & return it into main function . ; Function to find the sum of the first N centered hexadecagonal number ; Variable to store the sum ; Loop to iterate through the first N numbers ; Finding the sum ; Driver Code ; Display first Nth Centered_Hexadecagonal number
class GFG { public static int Centered_Hexadecagonal_num ( int n ) { return ( 8 * n * n - 8 * n + 1 ) ; } public static int sum_Centered_Hexadecagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_Hexadecagonal_num ( i ) ; } return summ ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( sum_Centered_Hexadecagonal_num ( n ) ) ; } }