public static void dfs ( int n , int curSum , int curBaseNum , int firstNum , int secondNum , Set < Integer > countedSet ) {
  if ( curSum > n ) {
    return ;
  }
  if ( ! countedSet . contains ( curSum ) && curSum > 0 ) {
    countedSet . add ( curSum ) ;
  }
  if ( curBaseNum < MaxNum ) {
    dfs ( n , curSum + firstNum * curBaseNum , curBaseNum * 10 , firstNum , secondNum , countedSet ) ;
    dfs ( n , curSum + secondNum * curBaseNum , curBaseNum * 10 , firstNum , secondNum , countedSet ) ;
  }
}

public static void dfs ( int n , int curSum , int curBaseNum , int firstNum , int secondNum , Set < Integer > countedSet ) { if ( curSum > n ) { return ; } if ( ! countedSet . contains ( curSum ) && curSum > 0 ) { countedSet . add ( curSum ) ; } if ( curBaseNum < MaxNum ) { dfs ( n , curSum + firstNum * curBaseNum , curBaseNum * 10 , firstNum , secondNum , countedSet ) ; dfs ( n , curSum + secondNum * curBaseNum , curBaseNum * 10 , firstNum , secondNum , countedSet ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier) (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier) (identifier))))))))