for (N = 100; N <= 100000000; N++)
{
}
which will take an enormous amount of time calculating lots of N values
you don't need. Instead, use something like:
for (N = 100; N <= 100000000; N *= 10)
{
}
which just calculates for 100, 1000, 100000, etc.