Let $f(x)$ is such function, that $f(x)=1$ for integer $x$ and $f(x)=0$ for non integer $x$. Build such function using only variable $x$, integer numbers, and operations $+,-,*,/,[.]$(plus, minus, multiply,divide and integer part)
Problem
Source: St Petersburg Olympiad 2014, Grade 11, P1
Tags: number theory, function
24.10.2017 16:14
RagvaloD wrote: Let $f(x)$ is such function, that $f(x)=1$ for integer $x$ and $f(x)=0$ for non integer $x$. Build such function using only variable $x$, integer numbers, and operations $+,-,*,/,[.]$(plus, minus, multiply,divide and integer part) $f(x)=\lfloor x\rfloor +\lfloor 1-x\rfloor$
22.12.2018 22:36
Assuming that, you have access to the internal states of the algorithm, here is my idea. For $x\in\mathbb{Z}$, $\frac{x}{x}=1$. If $x\notin \mathbb{Z}$, then compute first $\lfloor x\rfloor$, and obtain $\{x\}$. Now, $\lfloor \{x\}\rfloor =0$, as desired.
27.01.2019 16:34
$\left \lfloor{\frac{\lfloor x \rfloor}{x}}\right \rfloor$ also works. edit: lol
27.01.2019 16:53
oxide wrote: $\left \lfloor{\frac{\lfloor x \rfloor}{x}}\right \rfloor$ also works. It's not defined when $x=0$.
27.01.2019 19:55
oxide wrote: $\left \lfloor{\frac{\lfloor x \rfloor}{x}}\right \rfloor$ also works. No. Choose $x=-\frac 12\notin\mathbb Z$ and result is $2$