On Fri, Jun 1, 2012 at 2:50 AM, Spencer Pottebaum <lists / ruby-forum.com> wr=
ote:
> This is a homework question and I'm really confused by it:
>
> the method exp(x,y) is passed two integers and returns x^Y write a
> recursive version of exp(s,y) in Ruby.
>
> this is what I have:
>
> def exp(x,y)
>
> =A0if y =3D 1
> =A0return x
>
> return x * exp(x, y-1)
>
> is this correct?

No, you are missing an "end". ;-)

You could also include treatment for y =3D=3D 0.  (Hint: a case block might=
 help.)

Kind regards

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/