Quote Originally Posted by rockx View Post
I have got another question. the above code simply works fine. but is there any other way possible to further modify this
Of course there is. Prime number generation is one of the most-researched subjects in computer sciences and mathematics, so there's plenty of other variations out there to study.

This particular line does what its supposed to do:
if (i % j == 0)
however, is there any way possible to replace 'j' wtih all the numbers that have actually been generated?
What are you asking for? j already is being replaced with all candidate numbers to check for being an integral divider, time-sequentially within the loop.