static boolean isCyclic ( long N ) {
  long num = N ;
  int count = 0 ;
  int digit = ( int ) ( num % 10 ) ;
  boolean allSame = true ;
  while ( num > 0 ) {
    count ++ ;
    if ( num % 10 != digit ) allSame = false ;
    num = num / 10 ;
  }
  if ( allSame == true ) return false ;
  if ( count % 2 == 0 ) {
    long halfPower = ( long ) Math . pow ( 10 , count / 2 ) ;
    long firstHalf = N % halfPower ;
    long secondHalf = N / halfPower ;
    if ( firstHalf == firstHalf && isCyclic ( firstHalf ) ) return false ;
  }
  num = N ;
  while ( true ) {
    long rem = num % 10 ;
    long div = num / 10 ;
    num = ( long ) ( Math . pow ( 10 , count - 1 ) ) * rem + div ;
    if ( num == N ) break ;
    if ( num % N != 0 ) return false ;
  }
  return true ;
}

static boolean isCyclic ( long N ) { long num = N ; int count = 0 ; int digit = ( int ) ( num % 10 ) ; boolean allSame = true ; while ( num > 0 ) { count ++ ; if ( num % 10 != digit ) allSame = false ; num = num / 10 ; } if ( allSame == true ) return false ; if ( count % 2 == 0 ) { long halfPower = ( long ) Math . pow ( 10 , count / 2 ) ; long firstHalf = N % halfPower ; long secondHalf = N / halfPower ; if ( firstHalf == firstHalf && isCyclic ( firstHalf ) ) return false ; } num = N ; while ( true ) { long rem = num % 10 ; long div = num / 10 ; num = ( long ) ( Math . pow ( 10 , count - 1 ) ) * rem + div ; if ( num == N ) break ; if ( num % N != 0 ) return false ; } return true ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (false)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (return_statement (false))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (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)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) consequence: (return_statement (false))))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (while_statement condition: (parenthesized_expression (true)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (cast_expression type: (integral_type) value: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (identifier)) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (break_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) consequence: (return_statement (false))))) (return_statement (true))))