If the number is divisible by i , then insert it
if ( n % i == 0 ) { s . add ( n / i ) ; s . add ( i ) ; while ( m % i == 0 ) m /= i ; } } if ( m > 1 ) s . add ( m ) ; List < Integer > l = new ArrayList < Integer > ( s ) ; Collections . sort ( l ) ; Collections . reverse ( l ) ;