Let $A=(a_{ij})$ be the $n\times n$ matrix, where $a_{ij}$ is the remainder of the division of $i^j+j^i$ by $3$ for $i,j=1,2,\ldots,n$. Find the greatest $n$ for which $\det A\ne0$.
1. **Understanding the matrix $A$:**
   The matrix $A = (a_{ij})$ is defined such that each element $a_{ij}$ is the remainder when $i^j + j^i$ is divided by $3$. This means $a_{ij} = (i^j + j^i) \mod 3$ for $i, j = 1, 2, \ldots, n$.

2. **Analyzing the pattern for $i = 7$:**
   For $i = 7$, we need to check the values of $7^j + j^7 \mod 3$ for all $j$. Notice that:
   \[
   7 \equiv 1 \mod 3
   \]
   Therefore,
   \[
   7^j \equiv 1^j \equiv 1 \mod 3
   \]
   and
   \[
   j^7 \equiv j \mod 3 \quad \text{(since $j^7 \equiv j \mod 3$ by Fermat's Little Theorem for $j \in \{1, 2, \ldots, 6\}$)}
   \]
   Thus,
   \[
   7^j + j^7 \equiv 1 + j \mod 3
   \]
   This implies that the $7$-th row of $A$ is the same as the first row of $A$.

3. **Implication for the determinant:**
   If two rows of a matrix are identical, the determinant of the matrix is zero. Therefore, for $n \ge 7$, the determinant of $A$ is zero:
   \[
   \det A = 0 \quad \text{for} \quad n \ge 7
   \]

4. **Checking for smaller $n$:**
   We need to find the largest $n$ for which $\det A \ne 0$. According to the solution provided, a direct calculation shows:
   \[
   \det A = 0 \quad \text{for} \quad n = 6
   \]
   and
   \[
   \det A \ne 0 \quad \text{for} \quad n = 5
   \]

5. **Conclusion:**
   Therefore, the largest $n$ for which $\det A \ne 0$ is $5$.

The final answer is $\boxed{5}$