On 14 August 2011 05:56, Rahul <raikra...@gmail.com> wrote: > # To change this template, choose Tools | Templates > # and open the template in the editor. > > puts "Hello World" > def squareroot(a) > u=a > l=0 > while (l<=u) > m = l + (u-1)/2 > if (m**2) < a > l = m + 1 > elsif (m**2) > a > u = m-1 > elsif > m**2 == a > return m > else > return l-1 > > > end > end > end > x = squareroot(55) > print x
I guess it is never coming out of your while loop. Have a look at the Rails Guide on debugging to find out how to break into code using ruby_debug and see what is going on. Also you could try putting some write statements in the function to see what is happening. Hint: It may not help but what happens if you try squareroot(55.0)? If that helps make sure you understand why (using debug or print statements). Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.