阶乘和
1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 long b; 5 int w; 6 int c=0; 7 int f(int c){ 8 if(c==1){ 9 return 1; 10 }else{ 11 return c*f(c-1); 12 } 13 } 14 int d(int b){ 15 if(b==1){ 16 return 1; 17 }else{ 18 return f(b)+d(b-1); 19 } 20 } 21 22 int main(){ 23 24 25 int b; 26 cin>>b; 27 cout<<d(b); 28 return 0; 29 }

浙公网安备 33010602011771号