MATLAB: How to solve this question using two loops

loopsMATLAB

Best Answer

  • Big Hint:
    Suppose the grid is M x N. You've got (M+N) total moves to make, with M of them being "down" and N of them being "right". Suppose you number the moves 1,2,...,(M+N). How many ways can you pick M numbers from this ordered list of (M+N) numbers for the ordering of the "down" moves (the remaining numbers will be the "right" moves)? Figure that out, and what MATLAB function can be used to calculate it, and you will have your answer.