06-28-2003, 05:45 AM
Quote:Sorry, LooseCaboose, but this challenge is for Basic programs exclusively.
Oh well, I was just being pedantic because your rules don't state what langauge I have to write in. I have tested the code an it does work.
Like I said, its really hard to write one line algorithms in basic because all of the constructs (if, while, select, etc) require more than one line. Na_th_an's modulo counter was cool and Oracle's bit flip thing was neat, but as I said before the following works almost as well for flipping between an on and off state:
Code:
x = NOT x
Antoni's and Na_th_an's recursive functions are very clever, but don't actually obey your rules because they both use either the colon line separator or three lines with a proper function body, however seeing as you are accepting them heres one which calculates the sum of the values 1 to n:
Code:
function sum%(n as integer)
if n = 1 then sum% = 1 else sum% = n + sum%(n - 1)
end function
esus saves.... Passes to Moses, shoots, he scores!