static void Main(string[] args)
{
Random randgen = new Random();
UnicodeEncoding encoder = new UnicodeEncoding();
Console.ReadLine();
start:
var values = Array.Empty<string>();
int selectedNum = randgen.Next();
int x = selectedNum;
string localPath = (@"D:\COLLATZ\" + Convert.ToString(x) + ".txt");
Console.WriteLine("Input: {0}", selectedNum);
while (x > 0)
{
if (x == 1)
{
break;
}
if (x % 2 == 0)
{
x = x / 2;
Console.WriteLine("{0} | {1} | {2}", x, "div", Convert.ToString(x % 2));
}
else
{
x = (x * 3) + 1;
Console.WriteLine("{0} | {1} | {2}", x, "mul", Convert.ToString(x % 2));
}
values.Append(Convert.ToString(x));
}
File.WriteAllLines(localPath,values);
Console.WriteLine(String.Join(",", values));
Console.ReadKey();
goto start;
}
}
}
static void Main(string[] args)
{
Random randgen = new Random();
UnicodeEncoding encoder = new UnicodeEncoding();
Console.ReadLine();
start:
var values = Array.Empty<string>();
int selectedNum = randgen.Next();
int x = selectedNum;
string localPath = (@"D:\COLLATZ\" + Convert.ToString(x) + ".txt");
Console.WriteLine("Input: {0}", selectedNum);
while (x > 0)
{
if (x == 1)
{
break;
}
if (x % 2 == 0)
{
x = x / 2;
Console.WriteLine("{0} | {1} | {2}", x, "div", Convert.ToString(x % 2));
}
else
{
x = (x * 3) + 1;
Console.WriteLine("{0} | {1} | {2}", x, "mul", Convert.ToString(x % 2));
}
values.Append(Convert.ToString(x));
}
File.WriteAllLines(localPath,values);
Console.WriteLine(String.Join(",", values));
Console.ReadKey();
goto start;
}
}
}