WWright and anonymous_21321 have given nice formulas for your sequence. (Note that x is the zero-th term in those formulas-- you plug in n=0 or i=0 to get x.)
However, if you're trying to understand how to write a program for the sequence, a formula may not be the easiest way to go. What you wrote in your question is an algorithm for the sequence. To make it a program, you need to make it completely precise and clear.
In SAGE, I would write:
print x
i=1
while x-i >= 0:
print x+i
print x-i
i = i+1
print x+i
This is a direct translation of your description, written precisely for SAGE. With a little insight into the sequence, you could write a better program or even a formula for the n-th term, as the other answers do. If you're just interested in maxNum, there's a simple formula-- you can skip all the other terms in the sequence once you understand what's going on.