Martin DeMello wrote:
> On 6/6/07, Brad Phelan <phelan / tttech.ttt> wrote:
>>
>>
>> I am sure I just submitted this with a lengthy explanation but it
>> didn't appear in the list ??? So here it is again with no explanation
>> except that it minimizes method calls as much as possible by
>> avoiding modulo operation and maintaining separate counters.
>>
>>
>> f = 3
>> b = 5
>>
>> for i in 1..100 do
>>      if i == f
>>          if i == b
>>              puts "fizzbuzz"
>>              f += 3
>>              b += 5
> 
> Sadly, + (and hence +=) is a method call too :)
> 
> martin
> 

True but I think the overall method count will be lower
as the addition ops are only executed when the main
counter meets the correct conditions instead of
redundantly calculating the modulo for each loop
iteration.

--
Brad Phelan
http://xtargets.com