From: Ruby Newbie Date: 2007-09-19T16:10:28+09:00 Subject: Is Block passed to 'times' efficient over for loop Marcin Raczkowski wrote: > Marcin Raczkowski wrote: >>> funk(n - 1) - (2 × funk(n - 2)) otherwise >>> end >>> >> def rfib(n) >> b >> >> >> class :) >> >> > hmm i mistook Funkonacci with Fibonacci numbers and i guess you study on > university of texas ? > > how fun :) > > anyway: > > > def rfunk(n) > return 0 if n<1 > return 1 if n==1 > rfunk(n-1) - 2*rfunk(n-2) > end > > def ifunk(n) > return 0 if n<1 > return 1 if n==1 > a,b = 0,1 > (n-1).times do > a,b = b, b-2*a > end > b > end > > here's version fur that funky numbers of yours, but if you have to ask > ruby mailing list for such trivial home assigments you probably should > switch curses right now, or #mayby peaople in US are just that stupid# Giving racial or personal comments on the members should not be allowed in this forum. Moderators,(If some exists )Please look into this post To Understand a concept you dont need great problems to solve it cud be demonstrated in a simple problem. The solution you have given has been posted by the member already with a for loop.Do you mean using block over for loop improves the efficiency??????????????? Does using blocks improve it over using 'For'.Please give explanation. -- Posted via http://www.ruby-forum.com/.