```On May 31, 2012, at 17:50 , Spencer Pottebaum wrote:

> This is a homework question and I'm really confused by it:
>=20
> the method exp(x,y) is passed two integers and returns x^Y write a
> recursive version of exp(s,y) in Ruby.
>=20
> this is what I have:
>=20
> def exp(x,y)
>=20
> if y =3D 1
> return x
>=20
> return x * exp(x, y-1)
>=20
> is this correct?

Instead of answering you, I'm going to ask you how you'd answer it =
yourself.

Given the function:

def assert_equal expected_value, actual_value

you can write the following form:

assert_equal z, exp(x, y)

What triplets of [x, y, z] would you need to verify that your function =
is working correctly? Once you figure out what tests you need, knowing =
if your code is working is pretty much automatic. Put this in a file =
"test_exp.rb" and try it out:

require "exp"
require "minitest/autorun"

class TestHomework < MiniTest::Unit::TestCase
def test_exp
# ... fill in the blanks ...
end

def test_exp_negative_cases
# ... fill in the blanks ...
end

# ... etc ...
end

Once all the tests are running, you might want to ask yourself how many =
different ways your function can be implemented. You can then modify as =
you see fit and you'll always have your tests to verify that your =
modifications are still working.

```