#include<stdio.h> int main() { int n,s=0; int i,j; scanf("%d",&n); for( i=1;i<=n;i++) { int factorial=1; for( j=1;j<=i;j++) { factorial*=j; } s+=factorial; } printf("%d\n",s); return 0; }
#include<iostream.h> void main() { int i; int n; int sum=0,fact=1,j=1; cin>>n; for(i=1;i<=n;i++) { while(j<=i) { fact=j*fact; j++; } sum=sum+fact; } cout<<sum; }