Added danielfmt's Octave solution.