Hi guys!
I'm trying to print Pascal's triangle using the mathematical type
p(n,k) = (n! / (k! * (n-k)!)
In my C program i count n! using a for loop and i store the final value in an integer value named r1.
I do the same for k! (int r2) and (n-k)! (int r3).
The results from the for loops are correct cause i have tested them
The problem is when i try to count the p(n,k) where i have only to do a simple division,
I do:
int result = r1 / (r2 * r3);
printf("%d\n",result);
The only results i take from the division are 1 and 0.
e.g. p(2,1) = (2! / (1! * (2-1)!) = 2 / (1 * 1) = i shall take 2
I take 1!!!
Why?!?!?!
Thanks, in advance