Check if a given number is Pronic | Efficient Approach | Java program to check if a number is pronic or not ; Function to check Pronic Number ; Checking Pronic Number by multiplying consecutive numbers ; Driver Code
import java . io . * ; import java . util . * ; import java . math . * ; class GFG { static boolean pronic_check ( int n ) { int x = ( int ) ( Math . sqrt ( n ) ) ; if ( x * ( x + 1 ) == n ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 56 ; if ( pronic_check ( n ) == true ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }