Chủ Nhật, 4 tháng 1, 2015

tính S=1+ x + x^2 + x^3 +...+x^n



#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
int i=1,t=1,n,x;
printf("\n nhap gia tri x: "); scanf("%d",&x);
printf("\n nhap gia tri n: "); scanf("%d",&n);
do
{
t=t + pow(x,i);
i++;
}
while(i<=n);
printf("S= %d",t);
getch();
return 0;
}

Không có nhận xét nào: