Assignemnt #76 and seq
Code
///Name: Luke Shin
///Period: 7
///Project Name: seq
///File Name: seq.java
///Date: 01/05/2016
import java.util.Scanner;
public class seq{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int n=0;
int total=0;
System.out.print("#: ");
n = keyboard.nextInt();
while (n != 1)
{
System.out.print(n);
for (int i = 0;i < 10 - Integer.toString(n).length();i++)
System.out.print(" ");
if (n % 2 == 0) n = n / 2;
else n = 3*n + 1;
total++;
if (total % 10 == 0) System.out.print("\n");
}
System.out.println();
System.out.println("Total: "+ total+"!!!!!");
}
}
Picture of the output