Find out the factors of K less than N
for ( int i = 1 ; i <= sqrt ( k ) ; i ++ ) { if ( k % i == 0 ) { if ( k / i == i && i <= n ) factors . push_back ( i ) ; else { if ( i <= n ) factors . push_back ( i ) ; if ( k / i <= n ) factors . push_back ( k / i ) ; } } } return factors ; }