Well, you can, but as you noticed you'll have to make adjustments based on even and odd first.

Edit: Oh, and notice that "number of lines equals the input" isn't true -- the example for input=6 has five lines.