Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. float licz(int n)
  5. {
  6. float a1=0.5;
  7. float a2=1;
  8. if(n>2)
  9. return licz(n-1)+ 3*licz(n-2);
  10. else
  11. if(n==2)
  12. return a2;
  13. else if(n==1) return a1;
  14. }
  15. int main()
  16. {
  17. float n;
  18. cout<<"Podaj n: "<<endl;
  19. cin >> n;
  20. cout << licz(n);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement