Sunday, May 12, 2013

Collatz Conjecture In Python and ICE...

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:

if statement for colletz conjection

Collatz in Python:

To make this collatz conjecture I used a simple if statement, see code below... 

Python Collatz conjecture program
*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.

Collatz Conjecture in Softimage/ICE
*click to make bigger*

What that looks like:


End :D

P.S :

Post a Comment