News for hackers. Stuff that matters.
Re:The 3n+1 problem by kachnuv_ocasek on Thursday October 25, 2012 @12:51PM (#4698318)
Interesting article. For those not familiar with the problem, it's called the Collatz conjecture.

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.

Re:The 3n+1 problem by Dove on Thursday October 25, 2012 @01:11PM (#4698420)
In that case, I'd be much too excited about making progress in mathematics to be bothered by my toy program not working right.
Re:The 3n+1 problem by denzil_correa on Thursday October 25, 2012 @02:55PM (#4698955)
Yup - there are some other names to it too.

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://en.wikipedia.org/wiki/Collatz_conjecture

Re:The 3n+1 problem by Avshalom on Thursday October 25, 2012 @12:58PM (#4698347)
Not knowing much about the internals of the interpreter (other than proper tco) I would assume just your old fashioned infinite loop unless it got into bignum territory and got too large for memory.

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.

Re:The 3n+1 problem by lmm on Thursday October 25, 2012 @01:05PM (#4698394)
The function doesn't look to be tail-recursive, so my guess would be a stack overflow.

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.

Re:The 3n+1 problem by waterhouse on Thursday October 25, 2012 @01:25PM (#4698485)
It would be a stack overflow, except Racket does not stack overflow--it will grab more memory, make a bigger stack, and continue. Eventually your problem would be "out of memory".
Re:The 3n+1 problem by masterzora on Thursday October 25, 2012 @02:09PM (#4698719)
Of course, though it does mean you should examine it further to check.