Assignemnt #76 Sequences
Code
/// Name: Caelan Dorstad
/// Period: 6
/// Program Name: seq
/// File Name: seq.java
/// Date Finished: 2/19/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