Time or Fault?

1
2
3
4
5
6
7
for(b;b<10000000;b+=2)
	{
		if(b%3==0)
			b+=2;
		if(checkprime(b))
			a++;
	}


How much time will this loop takes?
Because for me its taking too long.
or is it due to some other problem?
What is b initialized to?
1
2
long a=2;
long long b=5;
Last edited on
How much time it takes depend on many different things. Your machine, your compiler and how much time is spent in the checkprime function. Checking if a number is a prime could be a slow operation so it might very well take long time.
It took more than 3 hours to complete half work.Thats too too much.

I have 2 gb ram and visual c++ 10.

Is there a way to reduce time?
Try write a more efficient checkprime function.

Also make sure that you have turned on full compiler optimizations. It will probably not make much difference but it's easy to do.
Topic archived. No new replies allowed.