Assignemnt #76: Collatz Sequence

Code

    /// Name: Cassie
    /// Period: 6
    /// Program Name: Collatz Sequence
    /// File Name: collatz.java
    /// Date Finished: 2/10/2016
    
    import java.util.Scanner;
    
    
    class collatz 
    {
    
        public static void main(String[] args)
        {
            Scanner keyboard = new Scanner(System.in);
            
            System.out.print("Starting Number: ");
            
            int n = keyboard.nextInt();
            System.out.println();
                while ( n != 1 )
                {
                    if ( ( n & 1 ) == 0 )
                    {
                            System.out.print( (n = ( n / 2 )) + " " );
                    }       
                    
                    else
                    {
                        System.out.print( (n = ( n * 3 ) + 1) + " " );
                    }
                        
                }
            System.out.println();
        }
    }
    

Picture of the output

Assignment 76