Respuesta :
I don't know what language you want it in but I will write this in Java.
public int isMultiple(int x, int y) {
if (x % y == 0)
return 1;
return 0;
}
The mod function (%) returns 0 iff x divides y.
Feel free to ask me questions!
public int isMultiple(int x, int y) {
if (x % y == 0)
return 1;
return 0;
}
The mod function (%) returns 0 iff x divides y.
Feel free to ask me questions!
Answer:
See the explanation
Explanation:
Given to integers a,b we can find integers k,r such that a = kb +r, where r is called the residue, where |r|<|b|. When r = 0, we say that a is a multiple of b. Based on that, we define the function %(a,b) which gives out the residue between a,b. For example %(4,3) =1 since 4 = 1*3 +1.
The main idea of the program should be: if the residue is 0, then they are multiples and it should return 1, otherwise, return 0.
Let us use the following syntaxis function name (parameter 1, parameter 2).
So, we have
isMultiple(a,b) {
if %(a,b)=0 (this means they are multiples)
then return 1
else return 0
end
}