Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float licz(int n)
- {
- float a1=0.5;
- float a2=1;
- if(n>2)
- return licz(n-1)+ 3*licz(n-2);
- else
- if(n==2)
- return a2;
- else if(n==1) return a1;
- }
- int main()
- {
- float n;
- cout<<"Podaj n: "<<endl;
- cin >> n;
- cout << licz(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement