can someone please help for me to change this function to iterative?

int recursive(int n)
    int total = 0;
        return recursive(n-1) + 2*recursive(n-2) + 2*recursive(n-3);
    else if(n>=2)
        return  total + recursive(n-1) + 2*recursive(n-2);
        return  total+1;

or at least a step in the right direction

Nevermind. I solved it.

Good to hear. Please remember to mark this solved thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.