# Collatz Counts Square

**URL:** <https://discourse.processing.org/t/collatz-counts-square/11467>\
**Category:** Gallery\
**Created:** [May 21, 2019, 4:23pm UTC](https://discourse.processing.org/t/collatz-counts-square/11467 "2019-05-21T16:23:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [May 21, 2019, 4:23pm UTC](https://discourse.processing.org/t/collatz-counts-square/11467/1 "2019-05-21T16:23:26Z")

</div>

Taking the steps from random numbers between a range of ( 4 , random ( 5 , 20 ) ) and pulling them into 4 and plucking those into a line it creates a cool square I tried with larger values and it always comes up as drawing a square.

 ![CollatzCount](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cbc747ec9f7b90a56ac08d70148802d363b46655.png)

What is Collatz ? Take a number now if that number is even / 2 if odd \* 3 + 1 keep repeating this until the number == 1 what I did is basically count for each number how much that loop runs and it creates this cool looking pattern.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 23, 2019, 5:08am UTC](https://discourse.processing.org/t/collatz-counts-square/11467/2 "2019-05-23T05:08:03Z")

</div>

> [@InferNova](#):
>
> pulling them into 4 and plucking those into a line

Do you mean that you are dividing a single random number into four groups of digits and then assigning those to x1,y1,x2,y2 ?

---

<div class="post-metadata">

**Author:** ![InferNova](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/infernova/32/6009_2.png) [@InferNova](https://discourse.processing.org/u/InferNova)\
**Post date:** [May 23, 2019, 7:10am UTC](https://discourse.processing.org/t/collatz-counts-square/11467/3 "2019-05-23T07:10:09Z")

</div>

I am creating four digits , where each is within the random constrain , after those are generated. Those are plugged in into Collatz and I count for each how many iterations it took in the loop to go down to == 1 and to be safe I use MAP so they all can fit on the screen. I have made something similar but with rect() I only provided pos.x and pos.y for each and it created also square like patterns. I also tested small values with this without MAP ( because one could say that because values are larger they are getting mapped ( squeezed )to smaller coordinates for the screen size and therefore producing similar spots ( Like for example when producing hashes for hash tables ) ), it produced the same pattern.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 24, 2019, 1:47pm UTC](https://discourse.processing.org/t/collatz-counts-square/11467/4 "2019-05-24T13:47:51Z")

</div>

Interesting. I’d love to see the sketch code if you are willing to share!
