Advertisement
murad45

Recursive

Sep 4th, 2021
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "Hello world!" << endl;
  8.     return 0;
  9. }
  10.  
  11. int Factorial(int n)
  12. {
  13.     if (n==0) // base case
  14.     return 1;
  15.     else
  16.     return n * Factorial(n-1);
  17. }
  18. int my_recursive_function (int x)
  19. {
  20.     if (x==1):
  21.         my_recursive_function (x) = 1;
  22.     else if (x >1):
  23.         my_recursive_function(x) = x + my_recursive_function (x-1);
  24.  
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement