So, you're writing your math program again, and you want to say that any amount y of apples can be roughly distrubuted amongst x baskets. You go on to say that at least one basket will have
apples, annd this generally seems to hold! Except, it only works when
Dang! How are you supposed to battle with that? How do we even figure out if an arbritary number divides another?
Here's one way.
Whenever x∣y, we will have that xy is an integer. We could simply compute that, and if it is an integer, then bingo! But, our function does not know how to test for an integer. So, we'll explicitly have to output 0 or 1.
There's a nice way we can get 0:
x ∣ y=xy−⌊xy⌋⇒{true:0, false: (0<?<1)} Right now, when it's false, we get whatever the residue of the floor is. That isn't very pretty - we'd ideally output the same thing every time it's false. We can do this easily with a ceiling function, but we'd much rather use a floor function since we've already used it once.
x ∣ y =xy−⌊xy⌋−1⇒{true:−1, false: (−1<?<0)} x ∣ y =−(xy−⌊xy⌋−1)⇒{true:1,false:(1>?>0)} x ∣ y =⌊−(xy−⌊xy⌋−1)⌋⇒{true:1, false:0} x ∣ y =⌊⌊xy⌋−xy+1⌋⇒{true:1, false:0} And this is perfect - if we want to add something only if x∣y, then we just multiply by this function - if it isn't true, it will just zero out!