I’m wondering what the simplest means of the following logic is: I want to check if the integer 10 (A) is a factor of variable [B].
- A is a factor of B = True/False?
- 10 is a factor of 30 = True
- 10 is a factor of 75 = False
The only way I can think to do this is a little messy, but should work:
- If ( (B/A) - ( Truncate (B/A) ) > 0 ,
then the result would be False.
Anyone know a simpler way?
Edit: I’m hoping to do this via blueprint
I guess I was a little misleading there, I’m actually looking for the means to do this in blueprint. I did try to explain my logic in the form of an equation, but I actually don’t know any coding.
If the B is also an integer, then try this:
If (B % A == 0)
//Do the thing
else you can try the fmod function from math.h
Translated in Blueprint it is this
Edit: Just saw you meant factor, then you have to switch A and B, the bigger one has to be on the top, else you will allways get the smaller one as the result.
Thanks! The Modulo component (and concept) is new to me. I tried googling what is going on here, could you tell me if my understanding is correct?
So if I understand this, the modulo node divides the first input by the second, and then outputs the remainder. The == node then checks to see if that remainder is equal to zero, and then outputs a boolean. Is that right?
Yea that is correct. Modulo allways gives you the remainder. 15%10=5 and 25%10= 5 too. If the remainder is 0 u know that the bigger number is perfectly tileable by the smaler one 20%10=0 30%10=0 15%5=0