1 Apr 2009 01:05
Re: Why does mathn kill this method?
Christopher Dicely <cmdicely <at> gmail.com>
2009-03-31 23:05:13 GMT
2009-03-31 23:05:13 GMT
On Tue, Mar 31, 2009 at 3:46 PM, Siep Korteling <s.korteling <at> gmail.com> wrote: > Really stumped here. > > def sum_digits(n) > sum = 0 > while n>0 > sum += n % 10 > n /= 10 > end > sum > end > > STDOUT.sync=true > > puts sum_digits(12) #=> 3 > > require 'mathn' > puts sum_digits(12) # hangs > > > What am I doing wrong? This should illustrate the problem: irb(main):001:0> require 'mathn' => true irb(main):002:0> n = 10 => 10 irb(main):003:0> n /= 10 => 1(Continue reading)
RSS Feed