Recursive call
checkIfPossibleRec ( x + a , a , b , isPossible , n ) ; checkIfPossibleRec ( x + b , a , b , isPossible , n ) ; } function checkPossible ( n , a , b ) { var isPossible = Array ( n + 1 ) . fill ( false ) ; checkIfPossibleRec ( 0 , a , b , isPossible , n ) ; return isPossible [ n ] ; }