Lucian_Adrian

#332 Expresie2

Sep 21st, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int fct(int n)
  5. {
  6. if(n == 0)
  7. return 0;
  8. else
  9. return fct(n - 1) + n * (n + 1);
  10. }
  11. int main()
  12. {
  13. int n;
  14. cin >> n;
  15. cout << "Rezultatul este" << ' ' << fct(n);
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment