Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long factor (int n)
- {
- int factorial = 1;
- for(int i = 1; i <= n; i ++)
- {
- factorial *= i;
- }
- return factorial;
- }
- long long factor2 (int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * factor2(n - 1);
- }
- }
- void stack_check (int n)
- {
- cout << n << endl;
- stack_check(++ n);
- }
- int main()
- {
- int n = 0;
- cin >> n;
- stack_check(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment