The 3n+1 problem
blog.racket-lang.org
blog.racket-lang.org
In 2007, researchers Kurtz and Simon, building on earlier work by J.H. Conway in the 1970s,[8] proved that a natural generalization of the Collatz problem is algorithmically undecidable.[7]
I'm curious how this would behave in case of the conjecture being false, i.e. found a number that wouldn't reduce to 1 by the algorithm.
I'm sure you could use contracts to prevent the latter and reasonably sure there's some option somewhere to set maximum recursion depth to prevent the prior.
EDIT: as opposed to boring method of just putting/checking a loop count accumulator and if not bignum? into the function body.
Of course, if you run it and get a stack overflow, you have no way of knowing whether the number was really a counterexample or just one that took many steps to reach 1.
The conjecture is also known as the 3n + 1 conjecture, the Ulam conjecture (after Stanisław Ulam), Kakutani's problem (after Shizuo Kakutani), the Thwaites conjecture (after Sir Bryan Thwaites), Hasse's algorithm (after Helmut Hasse), or the Syracuse problem; the sequence of numbers involved is referred to as the hailstone sequence or hailstone numbers,or as wondrous numbers.
http://projecteuler.net/problem=14
Also: "A Modified Collatz sequence": http://projecteuler.net/problem=277
There may be others.