Write a program to display the sum of the following series, in other words the sum of the factorial of the odd series.
1! + 3! + 5! + 7! + 9! + . . . + n!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem25
{
classProblem25
{
staticvoid Main(string[] args)
{
Console.WriteLine("\t\tName: Ehtesham Mehmood\n\t\tRoll No: 11014119-131\n\t\tSection: AE\n \t\t UOG\n");
int num;
int fact1=1;
int sum=0;
Console.WriteLine("Enter Number To Display The Sum Of The Following Series i.e. sum of the factorial of odd series\n Like This 1! + 3! + 5! + 7! + 9! + . . . + n!");
num = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= num; i++)
{
if (i % 2 != 0)
{
fact1 = 1;
for (int j = 1; j <= i; j++)
{
fact1 = fact1 * j;
}
sum = sum + fact1;
}
}
Console.WriteLine("\nThe Sum Of The Following Series: " + sum);
Console.ReadKey();
}
}
}
Output: