Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <stdio.

h>
#include <math.h>

int main(){
int n;
double x;
double lt = 1;
scanf("%d",&n);
scanf("%lf",&x);
if(n<=0){
printf("Error");
return 0;
}

double s = 1;
for(int i=1;i<=n;i++){
lt = - 1* lt * x;
s = s + lt;
}
printf("%.4lf",s);
return 0;
}

You might also like