Collatz Conjecture.
//3x + 1 Conjecture, or the Collatz Conjecture.
package visual;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
boolean run = true;
System.out.print("Enter the value of n: ");
long n = sc.nextLong();
int i = 0;
System.out.println(n);
while (run) {
i++;
if (n % 2 == 0) {
n = n / 2;
System.out.println(i + " : " + n);
} else {
n = (n * 3) + 1;
System.out.println(i + " : " + n);
}
if (n == 1) {
run = !run;
}
}
}
}