Program to check if N is a Centered Pentagonal Number or not | Java program for the above approach ; Function to check if number N is a centered pentagonal number ; Condition to check if N is a centered pentagonal number ; Driver Code ; Given Number ; Function call
import java . util . * ; class GFG { static boolean isCenteredpentagonal ( int N ) { float n = ( float ) ( ( 5 + Math . sqrt ( 40 * N - 15 ) ) / 10 ) ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int N = 6 ; if ( isCenteredpentagonal ( N ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }