Advertisement
Syndragonic

Self Exercise #12 CS311

Nov 3rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int mystery(int n);
  4. //Precondition n > = 1.
  5. int main()
  6. {
  7.  cout << mystery(3);
  8.  return 0;
  9. }
  10. int mystery(int n)
  11. {
  12.  if (n <= 1)
  13.  return 1;
  14.  else
  15.  return ( mystery(n - 1) + n );
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement