/**Recursion Demo 3
 * @author TK Rogers
 * @version 11-06-09
 */
public class Mystry {
    public static void main ( ) {
      System.out.println ( "Final Answer = " + mystry ( 3 ) ) ;
    }
   
    public static int mystry ( int y ) {
    // Output below is included only for understanding.       
    System.out.print ( " y = " + y ) ;
        if ( y == 0 ) {
            // Output below is included only for understanding.
            System.out.println ( "\n first return x = " + 1 ) ;
            return 1 ;
        } else {
             // Output below is included only for understanding
            System.out.print ( " else " ) ;
            int x = mystry ( y / 2 ) ;
            // Output below is included only for understanding
            System.out.println ( " x = " + x ) ;
            x *= x ;
 
            if ( y % 2 == 1 ) x *= 3 ;
             // Output below is included only for understanding
            System.out.println ( "\n return x = " + x ) ; 
            return x ;
        }
    }
}
 
/* code without the comments and output
    public static void main ( ) {
      System.out.println ( mystry ( 3 ) ) ;
    }
 
     public static int mystry ( int y ) {
        if ( y == 0 ) {
            return 1 ;
        } else {
            int x = mystry ( y / 2 ) ;
           
            x *= x ;
 
            if ( y % 2 == 1 ) x *= 3 ;
                return x ;
        }
*/