# If a program terminates and there is no one to see it, does it halt?

## JavaScript, 39

(function f(x){for(;x!=++x;)f(x+1)})(0)


### Explanation

Since JavaScript does not precisely represent large integers, the loop for(;x!=++x;) terminates once x hits 9007199254740992.

The body of the for loop will be executed Fib(9007199254740992) - 1 times, where Fib(n) is the nth fibonacci number.

From testing, I know my computer will do less than 150,000 iterations per second. In reality, it would run much slower because the stack would grow very large.

Thus, the program will take at least (Fib(9007199254740992) - 1) / 150000 seconds to run. I have not been able to calculate Fib(9007199254740992) because it is so large, but I know that it is much larger than 101000 * 150,000.

EDIT: As noted in the comments, Fib(9007199254740992) is approximately 4.4092*101882393317509686, which is indeed large enough.

## Python (9)

9**9**1e9


This has more than 10**10000000 bits, so computing it should take us far past heat death.

I checked that this takes more and more time for larger but still reasonable values, so it's not just being optimized out by the interpreter.

Edit: Golfed two chars by removing parens thanks to @user2357112. TIL that Python treats successive exponents as a power tower.

## CJam, 5 bytes

0{)}h


### How it works

 0   " Push 0.                                 ";
{   "                                         ";
) " Increment the Big Integer on the stack. ";
}h  " Repeat if the value is non-zero.        ";


This program will halt when the heap cannot store the Big Integer anymore, which won't happen anytime soon on a modern desktop computer.

The default heap size is 4,179,623,936 bytes on my computer (Java 8 on Fedora). It can be increased to an arbitrary value with -Xmx, so the only real limit is the available main memory.

### Time of Death

Assuming that the interpreter needs x bits of memory to store a non-negative Big Integer less than 2x, we have to count up to 28 × 4,179,623,936 = 233,436,991,488. With one increment per clock cycle and my Core i7-3770 (3.9 GHz with turbo), this will take 233,436,991,488 ÷ 3,400,000,000 > 1010,065,537,393 seconds, which is over 1010,065,537,385 years.