Tutorial :a short statement that consumes lots of CPU cycles



Question:

I'm seeking a(very) short statement(in any language) that can make the CPU busy for like a second or a half. The statement should consume CPU cycles, not IO stuff.


Solution:1

Psuedocode:

A = 2  StartTime = GetTime()  While (GetTime() - StartTime) < 1.0    A = A * 2  


Solution:2

Using java BigIntegers, you could try and implement http://en.wikipedia.org/wiki/Ackermann_function.

That'll keep you going for a while.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »