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
< ? php function countFact ( $ low , $ high ) { $ fact = 1 ; $ x = 1 ; while ( $ fact < $ low ) { $ fact = $ fact * $ x ; $ x ++ ; } $ res = 0 ; while ( $ fact <= $ high ) { $ res ++ ; $ fact = $ fact * $ x ; $ x ++ ; } return $ res ; } echo " Count ▁ is ▁ " , countFact ( 2 , 720 ) ; ? >