Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main(){
  6. int n, b;
  7. double fatorial=1, conta=0;
  8.  
  9. cin >> n;
  10.  
  11. n--;
  12.  
  13. while(n>=0){
  14. b = n;
  15. n--;
  16. fatorial=1;
  17. while(b>0){
  18.  
  19. fatorial = fatorial * b;
  20. b--;
  21. }
  22. conta += (1/fatorial);
  23. }
  24. cout << conta;
  25.  
  26. return 0;
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement