Centered triangular number | Java Program to find the nth Centered Triangular number ; function for Centered Triangular number ; formula for find Centered Triangular number nth term ; Driver Code ; For 3 rd Centered Triangular number ; For 12 th Centered Triangular number
import java . io . * ; class GFG { static int Centered_Triangular_num ( int n ) { return ( 3 * n * n + 3 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( Centered_Triangular_num ( n ) ) ; n = 12 ; System . out . println ( Centered_Triangular_num ( n ) ) ; } }