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;