em code như vầy đã đúng chưa ạ, e cám ơn
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
int n,x,t;
long p;
float s;
s=0;
t=1;
p=1;
cin>> n>>x;
for(int i=1;i<=n;i++){
t=t*x;
p=p*i;
if(i%2==1) s=s+(1.0*t/p)*(-1);
else s=s+(1.0*t/p)*1;
}
cout<< s;
return 0;
}