static void compositeSumProduct ( int arr [ ] , int n , int k ) {
  int max_val = max_val ( arr ) ;
  Vector < Boolean > prime = new Vector < > ( ) ;
  for ( int i = 0 ;
  i < max_val + 1 ;
  i ++ ) {
    prime . add ( i , Boolean . TRUE ) ;
  }
  for ( int p = 2 ;
  p * p <= max_val ;
  p ++ ) {
    if ( prime . get ( p ) == true ) {
      for ( int i = p * 2 ;
      i <= max_val ;
      i += p ) {
        prime . add ( i , Boolean . FALSE ) ;
      }
    }
  }
  int sum = 0 , product = 1 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( ! prime . get ( arr [ i ] ) && arr [ i ] % k == 0 ) {
      sum += arr [ i ] ;
      product *= arr [ i ] ;
    }
  }
  System . out . println ( "Sum of composite numbers " + "divisible by k is " + sum ) ;
  System . out . println ( "\nProduct of composite numbers" + " divisible by k is " + product ) ;
}

static void compositeSumProduct ( int arr [ ] , int n , int k ) { int max_val = max_val ( arr ) ; Vector < Boolean > prime = new Vector < > ( ) ; for ( int i = 0 ; i < max_val + 1 ; i ++ ) { prime . add ( i , Boolean . TRUE ) ; } for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime . get ( p ) == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) { prime . add ( i , Boolean . FALSE ) ; } } } int sum = 0 , product = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! prime . get ( arr [ i ] ) && arr [ i ] % k == 0 ) { sum += arr [ i ] ; product *= arr [ i ] ; } } System . out . println ( " Sum ▁ of ▁ composite ▁ numbers ▁ " + " divisible ▁ by ▁ k ▁ is ▁ " + sum ) ; System . out . println ( " \n Product ▁ of ▁ composite ▁ numbers " + " ▁ divisible ▁ by ▁ k ▁ is ▁ " + product ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (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: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (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)) 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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (field_access object: (identifier) field: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (true))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (assignment_expression left: (identifier) right: (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (field_access object: (identifier) field: (identifier))))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (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: (block (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (string_literal)) right: (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (string_literal)) right: (identifier)))))))