C# Program toward print sum regarding the factorial regarding odd series multiply with x where power regarding x is square regarding corresponding number
Program Statement:
Write a program toward display the sum regarding the following series i.e. sum regarding the factorial regarding odd series multiply with x where power regarding x is square regarding corresponding number.
X1*1! + X9*3! + X25*5! + X49*7! + X81*9! + . . . + Xn2*n!
Solution:
class _power
{
long n, f, x, sum = 0;
public long power(long a, long b)
{
long res = 1;
beneficial to (int i = 1; i <= b; i++)
res = res * a;
return res;
}
public void cal()
{
Console.WriteLine("\n\t\tSeries X^1*1! + X^9*3 +...+X^n2*n! \n");
Console.Write("\n\t\tEnter value regarding x : ");
x = Convert.ToInt32(Console.ReadLine());
Console.Write("\n\t\tEnter ending point : ");
n = Convert.ToInt32(Console.ReadLine());
beneficial to (int i = 1; i <= n; i++)
{
if (i % 2 != 0)
{
f = 1;
beneficial to (int j = i; j >= 1; j--)
f = f * j;
sum = sum + ((power(x, i * i)) * f);
}
}
Console.WriteLine("\n\t\tResult = {0}\n", sum);
}
}