int NumberOfRoutes = 0; function void countRoutes(int cur) { if (cur == N) { NumberOfRoutes++; return; } for(step = 1;step<=M;step++) { if(cur+step<=N) countRoutes(cur+step); } }