Calculate occurrence of an element in factorial of a number
static long legendre ( long factor , long num ) { long count = 0 , fac2 = factor ; while ( num >= factor ) { count += num / factor ; factor *= fac2 ; } return count ; } static boolean possible ( HashMap < Long , Integer > factors , long num ) { Set < Long > s = factors . keySet ( ) ;