C# program toward print sum regarding series
Program Statement:
Write a program toward display the sum regarding the following series using loop.
1*x + 2*x2 + 3*x3 + 4*x4 + 5*x5 + … + n*xn
Solution:
static void Main(string[] args)
{
int j, n = 1, x, lastn, sum = 0, prod = 1;
Console.WriteLine("Enter last digit:");
lastn=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter value regarding x:");
x = Convert.ToInt32(Console.ReadLine());
beneficial to (j = 1; j <= lastn; j++)
{
n = n * x;
prod = n * j;
sum = sum + prod;
}
Console.WriteLine("Sum regarding Series 1*x + 2*x2 + 3*x3 + 4*x4 + 5*x5 + … + n*xn when n=: " + n +" furthermore x= "+ x+ "sum= "+ sum);
Console.ReadLine();
}