Statement:
Consider the following operation on an arbitrary positive integer:
If the number is even, divide it by two.
If the number is odd, triple it and add one.
In modular arithmetic notation, define the function f as follows:
Collatz in Python:
To make this collatz conjecture I used a simple if statement, see code below...
*click to make bigger* |
Here is a video of how that all works with a gui:
Collatz in ICE:
In ICE I used the same idea as I used in python. Then just added a repeat node to get an updated n number.
No comments:
Post a Comment