public static long countPatties ( int level , long x ) {
  if ( x == 0 ) {
    return 0 ;
  }
  else if ( level == 0 ) {
    return 1 ;
  }
  else if ( x >= Burger . getHeight ( level ) - level ) {
    return Burger . getNumPatties ( level ) ;
  }
  if ( x < Burger . getHeight ( level - 1 ) + 2 ) {
    return countPatties ( level - 1 , x - 1 ) ;
  }
  else {
    return Burger . getNumPatties ( level - 1 ) + 1 + countPatties ( level - 1 , x - Burger . getHeight ( level - 1 ) - 2 ) ;
  }
}

public static long countPatties ( int level , long x ) { if ( x == 0 ) { return 0 ; } else if ( level == 0 ) { return 1 ; } else if ( x >= Burger . getHeight ( level ) - level ) { return Burger . getNumPatties ( level ) ; } if ( x < Burger . getHeight ( level - 1 ) + 2 ) { return countPatties ( level - 1 , x - 1 ) ; } else { return Burger . getNumPatties ( level - 1 ) + 1 + countPatties ( level - 1 , x - Burger . getHeight ( level - 1 ) - 2 ) ; } }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier)))) consequence: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)))) consequence: (block (return_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (return_statement (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal))))))))))