Count factorial numbers in a given range | Java Program to count factorial numbers in given range ; Function to count factorial ; Find the first factorial number ' fact ' greater than or equal to ' low ' ; Count factorial numbers in range [ low , high ] ; Return the count ; Driver code
class GFG { static int countFact ( int low , int high ) { int fact = 1 , x = 1 ; while ( fact < low ) { fact = fact * x ; x ++ ; } int res = 0 ; while ( fact <= high ) { res ++ ; fact = fact * x ; x ++ ; } return res ; } public static void main ( String [ ] args ) { System . out . print ( " Count ▁ is ▁ " + countFact ( 2 , 720 ) ) ; } }