public static long choose ( int n , int k ) {
  long ans = 1 ;
  ArrayList < Integer > toDiv = new ArrayList < Integer > ( ) ;
  for ( int i = 2 ;
  i <= k ;
  i ++ ) toDiv . add ( i ) ;
  for ( int i = n ;
  i >= n - k + 1 ;
  i -- ) {
    ans *= i ;
    for ( int j = 0 ;
    j < toDiv . size ( ) ;
    j ++ ) {
      if ( ans % toDiv . get ( j ) == 0 ) {
        ans /= toDiv . get ( j ) ;
        toDiv . remove ( j ) ;
        j -- ;
      }
    }
  }
  return ans ;
}

public static long choose ( int n , int k ) { long ans = 1 ; ArrayList < Integer > toDiv = new ArrayList < Integer > ( ) ; for ( int i = 2 ; i <= k ; i ++ ) toDiv . add ( i ) ; for ( int i = n ; i >= n - k + 1 ; i -- ) { ans *= i ; for ( int j = 0 ; j < toDiv . size ( ) ; j ++ ) { if ( ans % toDiv . get ( j ) == 0 ) { ans /= toDiv . get ( j ) ; toDiv . remove ( j ) ; j -- ; } } } return ans ; }
(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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (update_expression (identifier))))))))) (return_statement (identifier))))