Find the sum of the first Nth Centered Pentadecagonal Number | Java program to find the sum of the first N centered pentadecagonal number ; Function to find the centered pentadecagonal number ; Formula to calculate N - th centered pentadecagonal number ; Function to find the sum of the first N centered pentadecagonal numbers ; Variable to store the sum ; Driver Code
class GFG { static int Centered_Pentadecagonal_num ( int n ) { return ( 15 * n * n - 15 * n + 2 ) / 2 ; } static int sum_Centered_Pentadecagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_Pentadecagonal_num ( i ) ; } return summ ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( sum_Centered_Pentadecagonal_num ( n ) ) ; } }