Check if n is not in dp then only call the function so as to reduce no of recursive calls
if ( ! dp . has ( n ) ) dp . set ( n , 1 + Math . min ( n % 2 + count ( parseInt ( n / 2 ) ) , n % 3 + count ( parseInt ( n / 3 ) ) ) ) ;