I am trying to write a c++ program to find all numbers with a certain range say (1 till 3 billion) that are perfectly divisible by a number say N. I was wondering if I could get pointers to do this as efficiently as possible.
Very Basic:
for (i = 0; i < 3 BIllion; i++)
{
if (i % N == 0) print (i);
}
I am sure there will be better solutions, as this will take a long time. Would really appreciate a nudge in the right direction.
Rather than testing all numbers in turn, why not just explicitly generate the multiples?