a blog by Brie Gordon
Brie Gordon

I'm Brie, a 22 year-old graduate of Slippery Rock University's Computer Science department. My interests include Linux (generally and Ubuntu), networking, BSD-style operating systems including my own, BrieSD, translating English-Spanish-English for open source projects and LAMP configuration. Aside from that, I enjoy photography, making short films and soccer.

Posterous is one of my favorite new(ish) web sites!


brie@briegordon.com

       

Search

June 29th, 8:53am 0 comments

Collatz Conjecture - Python

Using Wikipedia’s pseudocode description of the Collatz Conjecture, I whipped something up in Python. Try it!


n = int(input("What number would you like to explore? "))
while n > 1:
     print(n)
     if n % 2 != 0:
         n = 3*n + 1
     else:
         n = n/2
print(n)

 

--

Brie

Comments (0)

Leave a comment...