TChi, this is a particularly simple question, so what you did isn't particularly egregious, but we here at PhysicsForums try to help people work through their problems (especially when it's homework). Homework should be in the Homework section (there's an Engineering and CompSci section), but there's also a Computer Science and Programming subforum as well (and there's a Mathematical Software section within that--for things like MATLAB, Octave and/or Mathematica)
EDIT: mods will occasionally delete responses that out-and-out answer questions (that should be answered by the question asker), and move homework to appropriate subforums. Not to snerk, just to let you know.