Program to check if N is a Star Number | Java implementation to check that a number is a star number or not ; Function to check that the number is a star number ; Condition to check if the number is a star number ; Driver code ; Function call
import java . io . * ; import java . util . * ; class GFG { static boolean isStar ( int N ) { double n = ( 6 + Math . sqrt ( 24 * N + 12 ) ) / 6 ; return ( n - ( int ) n ) == 0 ; } public static void main ( String [ ] args ) { int i = 13 ; if ( isStar ( i ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }