Advertisement
Raqeeb_Alnakib

Useful Summation of Factorials

Oct 19th, 2019
6,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. /*
  2.  
  3. Please, Don't Miss Visit My Site:
  4.  
  5.  
  6. https://global-prog.com
  7.  
  8.  
  9. */
  10.  
  11.  
  12.  
  13.  
  14. #include <iostream>
  15. using namespace std;
  16.  
  17. long int f(int n)
  18. {
  19.     return (n > 1 ? n*f(n-1) : 1);
  20. }
  21.  
  22. long int fCount(int n)
  23. {
  24.     long int count = 0;
  25.     for(int i = 1; i <= n; i++)
  26.     {
  27.         count += f(i);
  28.     }
  29.     return count;
  30. }
  31.  
  32. int main()
  33. {
  34. int N;
  35. cout<< "Enter Your Number: ";
  36. cin>>N;
  37.     cout << fCount(N);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement