This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
Run through the algorithm you coded and see if it ever is the case that x < 0. If not, that's the reason you're blowing your stack. To terminate the recursion, you need to find the correct condition for your base case.
Hint: It looks to me like you're almost there. Just that base case condition to work out.