Write a program to display the sum of the following series, in other words the sum of the factorial of the odd series multiplied by x where the power of x is the square of the corresponding number.
X1*1! + X9*3! + X25*5! + X49*7! + X81*9! + . . . + Xn2*n!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem27
{
classProblem27
{
staticvoid Main(string[] args)
{
int num;
int fact1 = 1;
int sum = 0;
int x;
int temp;
Console.WriteLine("Enter Number To Display The Sum Of The Following Series i.e.sum of the factorial of odd series multiply with x \n where power of x is square of corresponding number.\nX1*1! + X9*3! + X25*5! + X49*7! + X81*9! + . . . + Xn2*n!");
num = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= num; i++)
{
fact1 = 1;
if (i % 2 != 0)
{
for (int j = 1; j <= i; j++)
{
fact1 = fact1 * j;
}
x =i*i;
temp = x * fact1;
sum = sum + temp;
}
}
Console.WriteLine("\nThe Sum Of The Following Series: " + sum);
Console.ReadKey();
}
}
}
Output: