Computer Science Canada

Help with a few questions

Author:  hugonibs2 [ Thu Apr 16, 2009 7:59 am ]
Post subject:  Help with a few questions

What is it you are trying to achieve?
var number1 : int
var number2 : int
var intnumber : int
put "Please enter a Number: "..
get number1
put "Please enter another number: "..
get number2
if number2 mod number1 = then
put "", number1 , " is a multiple of ", number2
else
put "", number1 , " is not a multiple of ", number2
end if



What is the problem you are having?
When you reach the line if
number2 mod number1 = then
I'm trying to make it so that if the result of number2 mod number1 is a int then it would be
put "", number1 , " is a multiple of ", number2 but if it's a real then it will put "", number1 , " is not a multiple of ", number2
I can't seem to find a solution


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
Using version 4.1

Author:  jbking [ Thu Apr 16, 2009 8:35 am ]
Post subject:  Re: Help with a few questions

My guess would be that this condition:

code:
number2 mod number1 =


Is incomplete is the issue. What is number2 mod number1 supposed to equal for that condition to be true: 0,1,i, Timbuktu, or Purple Cow? Also, I think you have it backwards as x mod y = 0 implies that x is a multiple of y, not the other way around. If you want an example, consider 8 and 2, is 2 a multiple of 8 or is 8 a multiple of 2? I think it is the latter.

Author:  hugonibs2 [ Thu Apr 16, 2009 8:52 am ]
Post subject:  Re: Help with a few questions

Yes i understand that it is imcomplete. I do not know what i could place there to make it complete that is my question.

What could i place there (or add to the program) so that if can diustinguish the outcome from a whole number and a decila number

Author:  jbking [ Thu Apr 16, 2009 11:55 am ]
Post subject:  Re: Help with a few questions

Are you familiar with the concept of modulo arithmetic? If not, here is the crash course:

x mod y is basically computing the remainder of x divided by y. Typically, the result will be some integer between 0 and y-1 as for anything greater, one could simply subtract y over and over again to get a value in that range and for anything less than 0, add y over and over again to get a value in that range.

If x is a multiple of y, then the remainder is 0 to imply that there is nothing left over. For example, x mod x = 0 as x is a multiple of itself.

If the above doesn't make sense, please ask for where you need clarification as this is almost as basic as I can write it.

Author:  andrew. [ Thu Apr 16, 2009 4:21 pm ]
Post subject:  RE:Help with a few questions

Modulus is basically like long division. It's the remainder. An example is 8 mod 4. There is no remainder so the output would be 0. If you have 16 mod 5, the output would be 1 because that is the remainder.


: