got finite output (do... while)

hello. i am trying to make a program to prove Lothar Collatz formula. the program should produce output until the num = 1, but my code seems work pretty wierd. The output are only 6 (finite). i already try to figure it out what the problem but still cannot correct it. fyi, i am a beginner.

here is my code.

#include <iostream>

using namespace std;

int main ()
{
int x;

cout << " ##### This program will prove about LOTHAR COLLATZ formulae #####" << endl;

cout << endl;

cout << " Please enter any positive integer... : ";
cin >> x;

do
{
cout << x <<" ";

if (x % 2 == 1)
{
x = (3 * x) + 1;
}
else
x = x / 1;


}while (x != 1);




return 0;
}
Should be
x = x / 2;
not
x = x / 1;

If you succeed in "proving" it, please let us know.
I have done this for someone else here :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <cstdlib>
using namespace std;


int main()
{
	int inputNumber = 0;

	cout << "Please type number: ";
	cin >> inputNumber;
	

	for  (; inputNumber >= 2;)
	{
		if (inputNumber % 2 == 0)
		{
			inputNumber = inputNumber / 2;
			cout << inputNumber << " ";
		}
		else
		{
			inputNumber = ((inputNumber * 3) + 1);

			cout << inputNumber << " ";
		}
	}
	
	system("pause");

    return 0;
}
I think this came up under another sobriquet not so long ago, too:
http://www.cplusplus.com/forum/beginner/206995/#msg977825
owh... hahahah.. how can i miss look that things. its proved. thanks a lot btw
Topic archived. No new replies allowed.