Problem 15
Statement
Starting in the top left corner of a 2×2 grid, there are 6 routes (without backtracking) to the bottom right corner.

How many routes are there through a 20×20 grid?
Solution
The code, in C.
#include <stdio.h>
long long int gridRoutes(int s){
int i;
long long int m=1;
for(i=1;i<s+1;i++)
m=(m*((s+1)*2-1-i))/i;
return m;
}
int main(void){
printf("%lld\n",gridRoutes(20));
}
Answer
137846528820
SPEAK / ADD YOUR COMMENT
Comments are moderated.
Posts