Talk:Hailstone sequence: Difference between revisions

No edit summary
Line 36:
:: I meant maybe the sequence starting from that number overflowed. Try printing all the variables each time through the loop, or changing the exit condition to less than or equal to 1? --[[User:Paddy3118|Paddy3118]] 04:52, 14 July 2010 (UTC)
::: I'm not sure what you mean but the exit condition isn't working anyway, I've actually seen numbers result a 1,2,1,2,1,2 oscillation, ignoring the fact that 1 was reached already.
:::: Definitely an integer overflow. Not at the number 113383, but at the number 827370449 which is reached at the 119th step in the sequence starting at 113383. By attempting to compute 3n+1 from there, the result reached is 2482111348 upon which the variable num overflows to -1812855948. You can postpone this failure by defining your variables INTEGER*8 (I'm also sure you never saw a 1,2,1,2... but a -1,-2,-1,-2; which you can convince yourself is perfectly legal if you can ever reach negative numbers.) [[User:Sgeier|Sgeier]] 20:39, 24 August 2010 (UTC)
Anonymous user