ok heres my problem..

1. if x is even, divide x by 2.

2. if x is odd, multiply x by 3 and add 1, and count 1 step.

3. Repeat steps 1 and 2 until you arrive at the number 1.

For example, if we begin with 13, the sequence we obtain is:

13, 40, 20, 10, 5, 16, 8, 4, 2, 1

with 2 steps (from 13 to 40 and from 5 to 16).

this is my code so far... cant seem to get the loop working but i got the even/odd going...

thanks in advanced!!Code:#include <cstdlib> #include <iostream> using namespace std; int steps(int a); int main() { int month; cout<<"enter month: "<<endl; cin>>month; cout<<steps(month)<<endl; system("PAUSE"); return EXIT_SUCCESS; } int steps(int a) { int s = 1; int count = 0; int answer; for (int x = 0; x>1; x++) <---- i have a feeling something is wrong here... { if (a%2==0) { answer = a/2; } else { answer = (a * 3) + 1; count++; cout<<answer<<endl; } } return count; }