I've got a programing problem.
I've been trying to do something like a probability calculator in c#, for that I need a certain type of factorial. I know how to program factorial, but I need
sum of all the factorials from zero to some given number.
Suppose the input number is some constant r
, what I want is:
0! + 1! +2! + ... + (r-1)! + r!
This is what I've got so far, but still does not work:
double a, j, k = 1, sum = 1, l = 1;
for (a = 1; a <= f; a ++)
{
for (j = 1; j <= a; j++)
{
l = k * j;
}
sum = sum + l;
}
Console.WriteLine(sum);