tolord

Untitled

Sep 12th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long factor (int n)
  6. {
  7.     int factorial = 1;
  8.     for(int i = 1; i <= n; i ++)
  9.     {
  10.         factorial *= i;
  11.     }
  12.     return factorial;
  13. }
  14.  long long factor2 (int n)
  15.  {
  16.      if (n == 0)
  17.      {
  18.          return 1;
  19.      }
  20.      else
  21.      {
  22.          return n * factor2(n - 1);
  23.      }
  24.  }
  25.  
  26.  void stack_check (int n)
  27.  {
  28.      cout << n << endl;
  29.      stack_check(++ n);
  30.  }
  31.  
  32. int main()
  33. {
  34.     int n = 0;
  35.     cin >> n;
  36.     stack_check(0);
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment