{{ message }}

# Ulam / Hailstone / Collatz (3n+1) sequence#866

Open
opened this issue Jan 18, 2019 · 6 comments
Open

# Ulam / Hailstone / Collatz (3n+1) sequence#866

opened this issue Jan 18, 2019 · 6 comments

### metawops commented Jan 18, 2019

 Currently, it’s not possible to define the „hailstone numbers“ sequence where u(n+1) = 3*u(n)+1, if u(n) is odd, u(n+1) = u(n)/2, if u(n) is even. Please allow for such kinds of sequences. The text was updated successfully, but these errors were encountered:

 It is possible to define such a sequence, like so: `u(n+1)=(3*u_n)rem(u_n,2)+(u_n/2)rem(u_n+1,2)`. However, just because we can work around epsilon's limitations through creative abuse of existing functions doesn't mean we should settle for this.

### metawops commented Jan 18, 2019

 Hey, that's a cool hack! (You missed that +1, though, in the odd part ... 😉) Too bad it's not possible to tell the system to stop after a loop. (This sequence always ends in the loop 4-2-1 – which is still unproven, btw.!)

### metawops commented Jan 18, 2019

 There are no other graph styles, right? Like a bar graph or a line graph for sequences ...? 😳😞

### metawops commented Jan 18, 2019

 It is possible to define such a sequence, like so: `u(n+1)=(3*u_n)rem(u_n,2)+(u_n/2)rem(u_n+1,2)`. However, just because we can work around epsilon's limitations through creative abuse of existing functions doesn't mean we should settle for this. True, especially because this hack only works for this special kind of sequence where the two parts of the definition correspond to odd and even numbers which can be simulated via the rem(p,q) function. However, generic multi-part-definitions with arbitrary conditions won't always be possible by means of such a hack. 😉

### metawops commented Jan 18, 2019

 Also, what's the maximum value in a given interval would be an interesting fact to know. And how many steps were neccessary to reach a certain sequence value or loop (like 4-2-1) would be nice to know ... 😉

### AlainBusser commented Jan 30, 2019

 You can program this sequence in Python. I did it for a slightly simpler variant : https://workshop.numworks.com/python/alain-busser/collatz By the way Ulam did not discover this sequence, the idea came to Collatz in the 1930s while he was working on his PhD. Hasse made the sequence known to american mathematicians at Syracuse University during the 1950s.