static int getDifference ( int N ) {
  if ( N == 0 ) return 2 ;
  else if ( N == 1 ) return 1 ;
  else if ( isPrime ( N ) ) return 0 ;
  int aboveN = - 1 , belowN = - 1 ;
  int n1 ;
  n1 = N + 1 ;
  while ( true ) {
    if ( isPrime ( n1 ) ) {
      aboveN = n1 ;
      break ;
    }
    else n1 ++ ;
  }
  n1 = N - 1 ;
  while ( true ) {
    if ( isPrime ( n1 ) ) {
      belowN = n1 ;
      break ;
    }
    else n1 -- ;
  }
  int diff1 = aboveN - N ;
  int diff2 = N - belowN ;
  return Math . min ( diff1 , diff2 ) ;
}

static int getDifference ( int N ) { if ( N == 0 ) return 2 ; else if ( N == 1 ) return 1 ; else if ( isPrime ( N ) ) return 0 ; int aboveN = - 1 , belowN = - 1 ; int n1 ; n1 = N + 1 ; while ( true ) { if ( isPrime ( n1 ) ) { aboveN = n1 ; break ; } else n1 ++ ; } n1 = N - 1 ; while ( true ) { if ( isPrime ( n1 ) ) { belowN = n1 ; break ; } else n1 -- ; } int diff1 = aboveN - N ; int diff2 = N - belowN ; return Math . min ( diff1 , diff2 ) ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (decimal_integer_literal)) alternative: (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (return_statement (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (true)) body: (block (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement)) alternative: (expression_statement (update_expression (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (true)) body: (block (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement)) alternative: (expression_statement (update_expression (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))