C# Program toward print sum regarding factorial regarding Odd series
Program Statement:
Write a program toward display the sum regarding the following series i.e. sum regarding the factorial regarding odd series
1! + 3! + 5! + 7! + 9! + . . . + n!
Solution:
static void Main(string[] args)
{
int i, j, f,last, sum = 0;
Console.WriteLine("Enter Last value:");
last = Convert.ToInt32(Console.ReadLine());
i = 1;
while (i <= last)
{
f = 1;
j = i;
while (j >= 1)
{
f = f * j;
j--;
}
sum = sum + f;
Console.WriteLine("factorial regarding " +i+"="+f);
i = i + 2;
}
Console.WriteLine("sum regarding all factorial = " + sum);
Console.ReadLine();
}