Advertisement
nicuvlad76

Untitled

Jan 22nd, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. /**
  5. recursivitate indirecta
  6. f(n)= 1 n=1
  7. 3+g(n-1)altfel
  8. g(n)= 1 n=1
  9. 2*f(n-1)altfel
  10.  
  11. */
  12.  
  13.  
  14. ///prototipul functie g
  15. int G(int );
  16. ///functia f
  17. int F(int n)
  18. {
  19. if(n==1)return 1;
  20. else return 3+G(n-1);
  21. }
  22.  
  23. int G(int n)
  24. {
  25. if(n==1)return 1;
  26. else return 2*F(n-1);
  27. }
  28.  
  29.  
  30. int main()
  31. {
  32. int n;
  33. cin>>n;
  34. cout<<F(n)<<" "<<G(n);
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement