Precomputing all factors of integers from 1 to 100000
static void precompute ( ) { for ( int i = 0 ; i < factors . Length ; i ++ ) factors [ i ] = new List < int > ( ) ; for ( int i = 1 ; i <= 100000 ; i ++ ) { for ( int j = i ; j <= 100000 ; j += i ) { factors [ j ] . Add ( i ) ; } } }