Find the first natural number whose factorial is divisible by x | A simple Java program to find first natural number whose factorial divides x ; Returns first number whose factorial divides x . ; int i = 1 ; Result ; Driver code
class GFG { static int firstFactorialDivisibleNumber ( int x ) { int fact = 1 ; for ( i = 1 ; i < x ; i ++ ) { fact = fact * i ; if ( fact % x == 0 ) break ; } return i ; } public static void main ( String [ ] args ) { int x = 16 ; System . out . print ( firstFactorialDivisibleNumber ( x ) ) ; } }