Can anyone help me run this C program faster, it takes long to execute completely..!?
First of all this looks a lot like a school assignment, but I am going to trust you. The first thing I did was to turn on optimizations on the compiler. I assume that you have already done something like that, but I was able to make it run much faster by doing that. For gcc it is -O3 Next I ran a profiler and 91% of the time was beign spent in fibonacci. So I rewrote it to not recalculate everything that you already know. If you do go with a much larger number of loops try moving the fib cache off of the stack and onto the heap. You may need to look at ways to optimize the prime number checker then too. Before 7.533s After 0.004s #include