The problem is that you start getting to very, very large products, very, very quickly:
Look at the simple and obvious divisors of 512:
256, 128, 64, 32, 16, 8, 4, 2
Multiply them together:
256 * 128 * 64 * 32 * 16 * 8 * 4 * 2 = 68719476736
or 0x1000000000
Which
alreadydoesn't fit into a 32 bit integer!
Have a look at the divisors table:
http://www.positiveintegers.org/IntegerTables/501-600[
^] and you will see that some of these values can have 20 or more divisors!
These numbers get big
quickly and just getting to 10,000 or worse 100,000 is going to take considerable time and generate some incredibly large numbers.
Yes, you can do it - but you will need
BigInteger
rather than
ulong
and there isn't going to be much you can do with the numbers once you have generated them!
I don't know why you are doing this, but to be honest: I wouldn't bother!