$f:R \rightarrow R$
$f(x)$ = $(-1)^x$ $\lfloor(1+x)/2\rfloor$
So how do you prove it when you have a floor function?
$f:R \rightarrow R$
$f(x)$ = $(-1)^x$ $\lfloor(1+x)/2\rfloor$
So how do you prove it when you have a floor function?
Your function should be from the natural numbers $N$ to $Z$ where $N=\{0,1,2,...\}$ and $Z$ is the set of integers (positive, negative, zero whole numbers.
Then for even $x=2k$ we get $f(x)=k$ because the floor of $(2k+1)/2=k+1/2$ is $k$ and $(-1)^{2k}=+1.$
And for odd $x=2k-1$ we get $f(x)=-k$ since the floor of $((2k-1)+1)/2=k$ is $k$ and $(-1)^{2k-1}=-1$
To summarize: $f(2k)=k$ $f(2k-1)=-k$ From these you can see one to one and onto, since the even natural numbers are each divided by 2 to get one of the elements of $N$, and thus covering $N$ once, and the odd natural numbers cover the negative integers under $f$.
You can "see" how the function $f(x)$ is working by listing its values on $N$ for $x=0,1,2,...$: $0,-1,1,-2,2,-3,3,-4,4,-5,5,...$ This list of values obviously has each integer in it exactly once, so it's one to one and onto.