by Ricardo Fernández Serrata

Version 2 (April 13, 2021)

Download (14 downloads)

Returns the (Hailstone) sequence of a number that has passed through the Collatz Algorithm. This supports negative numbers and the use of the "shortcut version".

You can explicitly specify the iterations you want to apply to the number by using k. If k is falsy, the flow will halt when a known cycle is detected.

This uses {x % 2} instead of {x & 1} because bitwise operations don't work correctly on numbers larger than 31 bits. This doesn't happen in Javascript, JS performs wrap-around instead of AM's clamping. If you will never use such numbers, use the bitwise alternative for higher performance.

ℹ en.wikipedia.org/wiki/Collatz_conjecture

5 stars | 0 | |

4 stars | 1 | |

3 stars | 0 | |

2 stars | 0 | |

1 star | 0 | |

Reports | 0 |

Reviews and ratings can be submitted in the app.