private static int getCycleLength ( int n ) {
  Map < Integer , Integer > stateToIter = new HashMap < > ( ) ;
  int state = 1 ;
  for ( int iter = 0 ;
  ;
  iter ++ ) {
    if ( stateToIter . containsKey ( state ) ) return iter - stateToIter . get ( state ) ;
    else {
      stateToIter . put ( state , iter ) ;
      state = state * 10 % n ;
    }
  }
}

private static int getCycleLength ( int n ) { Map < Integer , Integer > stateToIter = new HashMap < > ( ) ; int state = 1 ; for ( int iter = 0 ; ; iter ++ ) { if ( stateToIter . containsKey ( state ) ) return iter - stateToIter . get ( state ) ; else { stateToIter . put ( state , iter ) ; state = state * 10 % n ; } } }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) 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))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (return_statement (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))))))))))