6. 84 For a finite set $A$, there exists a function $f: N \rightarrow A$ with the following property: if $|i-j|$ is a prime number, then $f(i) \neq f(j), N=\{1,2, \cdots\}$, find the minimum number of elements in the finite set $A$.


[Solution] Starting from 1, the smallest natural number whose difference with it is a prime number is 3; the smallest natural number whose difference with the previous two is a prime number is 6; the smallest natural number whose difference with the first three is a prime number is 8. This means that for the set $M=\{1,3,6,8\} \subset N$, for any two elements $i, j$, $|i-j|$ is a prime number, so the images of the elements in $M$ must be distinct. Therefore, $|A| \geqslant 4$.

On the other hand, we can construct the function $f$ as follows:
$f(x)=i$, where $x \in N, i \in A=\{0,1,2,3\}$ and $x \equiv$ $i(\bmod 4)$.

From the above construction, if $f(x)=f(y)$, then $x-y$ is divisible by 4, and $|x-y|$ is not a prime number. This means that the function $f$ we constructed has the property required by the problem. Since $|A|=4$ here, the minimum number of elements in set $A$ is 4.