+ 1

Write a program to find sum of the series. S= 1+x+x^2+....+x^n.

24th Nov 2017, 4:11 PM
Pritam Kumar
Pritam Kumar - avatar
3 ответов
+ 9
int x, n; cin >> x >> n; cout << ((pow(x, n + 1) - 1) / (x - 1));
24th Nov 2017, 4:30 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
here is a function : ... headed files void main etc. cin>>x; cin>>n; int I; int sum = 0; for(I=0;I<=n;I++) { sum+=pow(x,I); } cout<<sum;
24th Nov 2017, 4:18 PM
RZK 022
RZK 022 - avatar
0
// math header file included int x,n; cin>>x>>n; // Using sum of n terms of a GP cout<<'Sum of series: '<<x*(pow(x,n)-1) / x-1;
24th Nov 2017, 4:42 PM
#RahulVerma
#RahulVerma - avatar