What is the top down approach for it? I tried this

Replace the statement
dp[n]=numberOfWays(n-m,m-1,dp)+1;
with
dp[n]=numberOfWays(n-m,m,dp)+numberOfWays(n-1,m,dp);
will make it a more logical approach.