Hi,
Im normally pretty good with loops, but for some reason, im not able to understand this loop.
using System;
class Ques
{
public static void Main()
{
int i = 17;
while(i != 1)
{
Console.WriteLine("{0}", i);
i = 3*i + 1;
while(i%2 == 0)
i/=2;
}
}
}
The answer for this loop is: 17, 13, 5.
Can someone explain the process in each iteration? Thanks!
Im normally pretty good with loops, but for some reason, im not able to understand this loop.
using System;
class Ques
{
public static void Main()
{
int i = 17;
while(i != 1)
{
Console.WriteLine("{0}", i);
i = 3*i + 1;
while(i%2 == 0)
i/=2;
}
}
}
The answer for this loop is: 17, 13, 5.
Can someone explain the process in each iteration? Thanks!