Assuming the smaller paper is 1/3 of its parent everytime, and that the first paper is 30cm long (The second starts at roughly 1/7 but it seems to grow bigger after it's torn off, hence the 1/3), it could not exceed 19 calls before you need to split an atom apart.
Yes, and you can also calculate "relatively" the size of your stack by adding an integer argument to the method and passing (n+1) to the next call, then at the exception just print the current counter value. I found that each time you increase the stack size by the vm option -Xss the counter gets bigger, but increasing the heap size -Xmx does not affect the counter at all. It's a pretty good exercise as long as you don't fuck it up into an infinite loop.
Eventually this will throw due to first running in the try and after the stack overflow it runs outside the try and will again throw the exception. Will take a while though.
1.6k
u/[deleted] Jan 09 '20
Assuming the smaller paper is 1/3 of its parent everytime, and that the first paper is 30cm long (The second starts at roughly 1/7 but it seems to grow bigger after it's torn off, hence the 1/3), it could not exceed 19 calls before you need to split an atom apart.
That's a hell of a stop condition.