Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) Ruby Methods Method Returns: Part 2

why isnt this working?

irb(main):014:0> def mod(a, b) irb(main):015:1> #write your code here irb(main):016:1* puts "The remainder of #{a} divided by #{b} is #{a % b}." irb(main):017:1> end => nil irb(main):018:0> mod(400, 1000) The remainder of 400 divided by 1000 is 400. => nil

1 Answer

Hey Brian,

It looks like your function is working correctly. Could you be more specific about what's not working? If you mean the result of 400 % 1000, then I think it's working correctly.

400 % 100 => 400

This is because in Ruby, integer division will return 0 for a smaller number divided by a larger number.

400 / 1000 => 0 (the remainder is therefore 400)