-1

Let $a,x,y \in \mathbb{N}$ with $ax \ge y$, and let % be the remainder from integer divison, always positive. Define $$A:=y \text{%} a + (a x -y) \text{%} a.$$Then using the distributive property for %, it is true that $A$%$a=0$. From this we infer that there exists an $n : \mathbb{N}^3 \rightarrow \{0,1\}$ such that $$A = a n(x, y).$$

It is clear that $n(x, y) = \frac{y \text{%} a + (a x -y) \text{%}a}{a}.$ How can I simplify the form of $n$ to express it without the division by $a$?

Jojo
  • 1,304

1 Answers1

1

If $a \mid y$, then clearly $n(x,y,a) = 0$.

And if $a\nmid y$, then already $y \% a > 0$, so $A$ being the sum of this positive term and something else non-negative is positive and we have to have $n(x,y,a)>0$. Since $A<2a$, we have $n(x,y,a)=1$ in this case.

ploosu2
  • 8,707
  • Thanks for your answer. If I used $(-x)%a<0$, would that mean that $n=0$ identically? – Jojo Sep 08 '22 at 06:43
  • @Joe Well for these numbers with $ax \geq y$ the outcome wouldn't change, would it. So you still have these cases. But for $ax<y$ yes I believe you would get $n=0$ identically. – ploosu2 Sep 08 '22 at 06:49
  • Well, with even with $ax>y$ then I can write $A= y%a + (-y)%a$, and then I'm wondering if some programming languages define $(-x)%a := -(x%a)$, which would give $A=0$? It seems counterintuitive to me to have $x%a <0$ – Jojo Sep 08 '22 at 07:31
  • If ever $(-x)%a$ is defined to be $-(x%a)$, then it is no longer always true that $(ax-y)%a = (-y)%a$. (Which is one of many reasons that $(-x)%a := -(x%a)$ is a terrible definition.) Simple experiments with $x=0$, then $x=1$, ... will demonstrate that there's no nice formula for the sum in the OP under this alternate convention. – Greg Martin Sep 08 '22 at 15:41
  • @GregMartin yes I was thinking this after I made that comment. What is the consistent definition that allows for $y%a<0$ when $y<0$? – Jojo Sep 09 '22 at 14:53
  • There is no such consistent definition, in my experience. – Greg Martin Sep 09 '22 at 19:43