The concept behind this method is that the prime factorization of a number determines all of its factors. If a number is divisible by 2, for instance, 2 will be a factor of many of the number’s factors. In fact, each factor of a number is built up of one or more of the number’s other factors.
Take 18, for instance. The prime factors of 18 are 2 and 3; the prime factorization is 2 times 3 times 3, or (2^1)(3^2).
Consider each of 18’s factors in terms of its own prime factorization:
 1 = (2^0)(3^0)
 2 = (2^1)(3^0)
 3 = (2^0)(3^1)
 6 = (2^1)(3^1)
 9 = (2^0)(3^2)
 18 = (2^1)(3^2)
If you look at all of those numbers in terms of their factorizations, you’ll see every possible arrangement of 2 to the 0 or 1 power with 3 to the 0, 1, or 2 power. That’s no accident.
To generalize that method, here’s your approach:
 Find the prime factorization of a
number (each one of the number’s
prime factors raised to the
appropriate power).
 List all of the exponents.
 Add one to each of the exponents.
(Remember, it’s possible to raise the
prime factor to the zero power.)
 Multiply the resulting numbers.
For example find number if factors of 196:
 The prime factorization: 196 =
(2^2)(7^2)
 The powers: 2 and 2
 Add one to the powers: 3 and 3
 Multiply the results: (3)(3) = 9
There are 9 factors of 196. To see what those are, work through the permutations of the exponents 0, 1, and 2 for the prime factors 2 and 7:
*(2^0)(7^0) = 1
(2^1)(7^0) = 2
(2^2)(7^0) = 4
(2^0)(7^1) = 7
(2^1)(7^1) = 14
(2^2)(7^1) = 28
(2^0)(7^2) = 49
(2^1)(7^2) = 98
(2^2)(7^2) = 196*

SO general approach to solving your
problem would be to find all prime
numbers upto 10^6 using sieve method

Then find prime factors of the said
numbers and their exponents

add 1 to each exponent

multiply the exponents to get the
answer
PS: If you need it coded, please request.