Store a factor for every value
For each , let be its smallest prime factor. For a prime , this gives .
Build the table once through the largest query value. Each later factorization can use the stored factors directly instead of searching for divisors.