View Single Post
  #2 (permalink)  
Old 11-02-2007, 08:16 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,119
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Sorry I'm unfamiliar with Python, but if you've the function already...

Quote:
hail(x) = x/2
and

Quote:
hail(x) = 3x+1
Then write something like:

Pseudo code:
Code:
Integer Function hailEven(Integer x)
     return x/2
End Function hailEven

Integer Function hailOdd(Integer x)
     return 3x+1
End Function hailOdd

Main method
    Integer Command
    Do
        Show.Output("Enter integer (-1 to exit): ")
        Command = Get.InputStream
        If Command % 2 = 0 // This is even
           hailEven(Command)
        Else // Odd
           hailOdd(Command)
        End If
    While (Command is not -1)
End Main
I hope that helps

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote