#include <iostream>
usingnamespace std;
int ipow( int base, int exponent )
{
int result = 1;
for ( int i = 1; i <= exponent; i++ ) result *= base;
return result;
}
int main()
{
int x = 0;
while ( x != 4 )
{
cout << "\nPlease choose which function you would like: "<<endl;
cout << "1. X(n) = 5*X(n-1)-7, X(0)=1\n";
cout << "2. F(n) = 3*F(n-1)-2*F(n-2), F(0)=1, F(1)=0\n";
cout << "3. G(n) = G(n-1) + 2*G(n-2) - 3*n, G(2)=1, G(3)=4\n";
cout << "4. Quit\n";
cin >> x;
if ( x >=1 && x <= 3 )
{
int n, ans;
cout << "Enter n: ";
cin >> n;
switch( x )
{
case 1: ans = ( 7 - 3 * ipow( 5, n ) ) / 4; break;
case 2: ans = 2 - ipow( 2, n ); break;
case 3: ans = ( -10 * ipow( 2, n ) - 29 * ipow( -1, n ) + 18 * n + 45 ) / 12; break;
}
cout << "Result = " << ans << '\n';
}
}
}