so I've written some C++ code which checks a 2^68 for a few calculations, and during the calculations, if it ever reaches 1, 2 or 4, it's supposed to end the calculations for it, add 1 to the initial number, and then repeat the whole process again. However, it doesn't seem to add 1 to the variable, and repeats the process for the same number over and over again.
Please let me know what is my issue. I've tried multiple methods, but they all seem to fail.
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
void p(string s)
{
cout << s + "\n\x1b[0m";
}
void cls()
{
p("\033[2J\033[1;1H");
}
long double is = pow(2, 68);
long double x;
long double z;
long double i2 = (is / 2.0);
long double x2 = (x / 2.0);
long double z2 = (z / 2.0);
long double rem, fraction;
int main()
{
cout.precision(200);
while (3 > 2)
{
if ( modf(i2, &rem) != 0)
{
x = ((3.0 * is) + 1.0);
}
else
{
x = (is / 2.0);
}
while (3 > 2)
{
if ((x == 1.0) || (x == 2.0) || (x == 4.0))
{
cout<<is<<" Doesn't Work"<<endl;
is += 1.0;
break;
}
if (x == is)
{
p(to_string(is));
p("success! Counterexample found!");
break;
}
else
{
if ( modf(x2, &rem) != 0)
{
z = ((3.0 * x) + 1.0);
}
else
{
z = (x / 2.0);
}
}
if ((z == 1.0) or (z == 2.0) or (z == 4.0))
{
cout<<is<<" Doesn't Work"<<endl;
is += 1.0;
break;
}
if (z == is)
{
p(to_string(is));
p("success! Counterexample found!");
break;
} else {
if ( modf(z2, &rem) != 0)
{
x = ((3.0 * z) + 1.0);
} else {
x = (z / 2.0);
}
}
}
}
return 0;
}
Any help is appreciated.