Skip to content

Instantly share code, notes, and snippets.

@Blinhy0131
Last active February 20, 2022 09:39
Show Gist options
  • Save Blinhy0131/da2bec7162dc9bd005e9be9b84477c43 to your computer and use it in GitHub Desktop.
Save Blinhy0131/da2bec7162dc9bd005e9be9b84477c43 to your computer and use it in GitHub Desktop.
sigma 求和
#include<stdio.h>
void main(){
int k,x,p=1,sum=0,ans;
float sig=0;
FILE *fpr=fopen("d.txt","r");
fscanf(fpr,"%d\n %d",&x,&k);
for (int i=1;i<=k;i++){
sum=i;
for(int t=sum-1;t>0;t--){
sum=sum*t;
}
sig=sig+pow (x,i)/sum;
}
ans=(int)sig;
printf("%d\n",ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment