Count factorial numbers in a 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
function countFact ( low , high ) { let fact = 1 ; let x = 1 ; while ( fact < low ) { fact = fact * x ; x ++ ; } let res = 0 ; while ( fact <= high ) { res ++ ; fact = fact * x ; x ++ ; } return res ; } document . write ( " " + countFact ( 2 , 720 ) ) ;