From: Derek Perrault Date: 2007-02-18T11:49:40+09:00 Subject: Re: modulus/division.. ------=_Part_14570_1064019.1171766978129 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Modulus division =3D Remainder division Two goes into five two times, with one left over. 5 / 2 =3D 2 (R1). Modulus division only returns that remainder. 5 % 2 =3D 1 Note that, when divided by 2, odd numbers always return 1, while even numbers always return 0. On 2/17/07, Derek Derek wrote: > > hey guys, i am reading that "learning to program" by Chris Pine still > and at the end of each lesson they give you a "give this a try" thing > for you practice what you've learned... Anyway, at the end of Chapter 9 > they give you this to try. I sort of have an idea of what i should do, > but i really just don't understand the modulus(%) stuff, i was wondering > if you guys could help me with just understanding what modulus is and > how it works, thank you! > > BELOW IS THE PROBLEM THEY GIVE ... > > Old-school Roman numerals. In the early days of Roman numerals, > the Romans didn=C3=D5 bother with any of this new-fangled subtraction > IX nonsense. No sir, it was straight addition, biggest to littlest - > so 9 was written VIIII, and so on. Write a method that, when > passed an integer between 1 and 3000 (or so), returns a string > containing the proper old-school Roman numeral. In other words, > old_roman_numeral 4 should return 'IIII'. Make sure to test > your method on a bunch of different numbers. Hint: Use the integer > division and modulus methods on page 36. > For reference, these are the values of the letters used: > I =3D 1 V =3D 5 X =3D 10 L =3D 50 > C =3D 100 D =3D 500 M =3D 1000 > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_14570_1064019.1171766978129--