S
Siep Korteling
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?
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?