Forums - C# Corner

Forum guidelines
harish reddy

harish reddy

  • 1.5k
  • 101
  • 4.3k

Program output for loop

Dec 17 2017 11:01 PM
//Write a program in C# Sharp to display the sum of the series [ 1+x+x^2/2!+x^3/3!+....]
int x = int.Parse(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
int sum = 1 + x;
int top;
for (int i = 2; i <= n; i++)
top = x ^ i;
sum = sum + top;
Not able to proceed further. pls help. Also can we use X^i for powering a number?
My main doubt is how can i put factorial also in the above loop...
I see many answers in google for the above program. but not able to understand. can someone help with using the above code i did. 

Answers (5)