Hi Daniweb community. This is my first post. I'm new to this programming lark and I've hit a snag with an exercise I'm attempting.
EXERCISE
Write a program that asks the user to type an integer N and compute u(N) defined with :
u(0)=3
u(n+1)=3*u(n)+4
My Attempt:
// Iteration
#include <iostream>
using namespace std;
int main ()
{
int u[]={}, N, i;
cout << "Choose an integer N: " << endl;
cin >> N;
u[0]=3;
for (i=0;i<=N;i++)
{
u[i+1]=(3*u[i])+4;
}
cout << "u(N) is given by: " << u[i] << endl;
return 0;
}
The problem I'm having is that it is performing the iteration as though the initial value is 0. How could I set it to 3?