```
public int uniquePaths(int m, int n) {
int smaller = m>n ? n-1 : m-1;
int totalsteps = m+n-2;
long result = 1;
for (int counter = 1; counter<=smaller; counter++){
result *= totalsteps--;
result /= counter;
}
return (int)result;
}
```

Basically it is math: select m (or n) from [(m-1)+(n-1)]