From: Michael Orlitzky Date: Fri, 14 Sep 2012 23:44:26 +0000 (-0400) Subject: Add even/odd Octave functions. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=bc6acf9a05d6e6acc6c1d0c802e783fbc45b3bb1;p=octave.git Add even/odd Octave functions. --- diff --git a/even.m b/even.m new file mode 100644 index 0000000..f4f3767 --- /dev/null +++ b/even.m @@ -0,0 +1,14 @@ +function even = even(integer_n) + ## Returns true if its argument is even; false otherwise. + ## + ## INPUTS: + ## + ## * ``integer_n`` - The integer whose parity you're determining. + ## + ## + ## OUTPUTS: + ## + ## * ``even`` - True if `integer_n` is even, false otherwise. + ## + even = rem(integer_n, 2) == 0; +end diff --git a/odd.m b/odd.m new file mode 100644 index 0000000..b0bc626 --- /dev/null +++ b/odd.m @@ -0,0 +1,15 @@ +function odd = odd(integer_n) + ## Returns true if its argument is odd; false otherwise. + ## + ## INPUTS: + ## + ## * ``integer_n`` - The integer whose parity you're determining. + ## + ## + ## OUTPUTS: + ## + ## * ``odd`` - True if `integer_n` is odd, false otherwise. + ## + + odd = !even(integer_n); +end