Clarify comment

This commit is contained in:
daniele 2019-09-23 07:58:22 +02:00
parent ab6ab1f4ad
commit 8338e81670
Signed by: fuxino
GPG Key ID: 6FE25B4A3EE16FDA

View File

@ -1,3 +1,6 @@
/* Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner
* How many such routes are there through a 20×20 grid?*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@ -11,6 +14,11 @@ int main(int argc, char **argv)
clock_gettime(CLOCK_MONOTONIC, &start);
/* Using a combinatorial solution: in a 20x20 grid there will always be
* 20 movements to the right and 20 movements down, that can be represented
* as a string of Rs and Ds. The number of routes is the number of combinations.
* This is obtained calculating n!/(k!*(n-k)!), where n=40 and k=20. The GMP
* Library is used to calculate the factorials.*/
mpz_inits(count, tmp, NULL);
mpz_fac_ui(count, 40);
mpz_fac_ui(tmp, 20);