Check if n is divisible by 3
if ( n % 3 == 0 ) { Vector < Integer > div_by_3 = find_sequence ( n / 3 ) ; if ( div_by_3 . get ( 0 ) < ans . get ( 0 ) ) { ans . clear ( ) ; ans . add ( div_by_3 . get ( 0 ) + 1 ) ; ans . add ( n / 3 ) ; } }