Re: Pseudo code Standard
Posted: Wed Mar 24, 2010 2:26 pm
We must always encourage people to write something their own first. Doesn't matter it is incorrect. Here is a simple pseudo code. See whether you can improve it. There is a little advance algorithm technique called recursion. You might try to use here as well.
See whether this helps!
Code: Select all
number = raw_input("Please enter an integer: ")
itemCount = 0
maxNum = number
IF (number != 0) THEN // != is used to denote "not equals"
WHILE (number != 4) // && is used to conditional AND operator
print (number + ", ")
IF (number & 1) THEN // odd number (Note & is used to bitwise AND operation)
number = number * 3 + 1
ELSE
number = number / 2
END IF
IF (maxNum < number) THEN // Set max number
maxNum = number
END IF
itemCount = itemCount + 1
ENDWHILE
println (number + ", 2, 1") // println is used to print on a new line
println ("Total items " + itemCount)
println ("Largest Number in Sequence " + maxNum)
ELSE
println ("Invalid number entry")
END IF