Find a non injective function between a set of integers and itself Say we have a set of integers:
$ A = \left\{1,2,6,8\right\}$ is there any way to find a non-injective function that when fed any of the numbers in $A$ gives another number in $A$ (Basically a non-injective surjection between $A$ and itself)
EDIT: To clarify, set $A$ is an example. I want to know a general algorithm for determining a function to do this with any set.
 A: If $A$ is finite, you cannot do this. The reason is that if $A$ is a finite set, then $f\colon A\to A$ is injective if and only if it is surjective if and only if it is bijective.
If you just look for a non-injective function without fixed points (namely, it never satisfies $f(x)=x$), you can do it granted $A$ has at least two elements.
Pick $a,b\in A$ and define $f(x)=\begin{cases} a & x\neq a\\ b & x=a\end{cases}$.
A: Let's forget "injective" and "surjective" for a moment. It sounds as if the thing you want might be this:
(a) for every $a \in A$, we have $f(a) \ne a$, and 
(b) for every $a \in A$, there's some element $p$ with $f(p) = a$.
The second of these is called "surjectivity," but the first is not called "non injectivity" --- I'm not sure that it has a name. 
In general, the answer is "yes" (except in one special case). One solution breaks into five cases:


*

*$A$ is empty. The vacuous function satisfies both conditions. 

*$A$ has one element: then there's only one function from $A$ to $A$, and it satisfies condition (b), but not condition (a). 

*$A$ is finite, nonempty Then number the elements in increasing order, so that
$$
a_1 < a_2 < a_3 < \ldots < a_k
$$
for some $k \ge 2$. Define $f(a_1) = a_2, f(a_2) = a_3, \ldots, f(a_{k-1}) = a_k$, and $f(a_k) = a_1$. 

*$A$ is infinite, but bounded below (i.e., it has a least element). Again, place the elements in increasing order, and define
$$
f(a_1) = a_2, f(a_2) = a_1 \\
f(a_3) = a_4, f(a_4) = a_3 \\
...
$$
and so on.  The case where $A$ is infinite but  bounded above is similar. 

*$A$ is infinite, but neither bounded below nor above. Again, the elements of $A$ can be ordered by "less than"; define $f$ to send each element $a\in A$ to the next higher element of $A$ (much as in case 3, but without the "wrap around" for the "last" element)). 
