$\DeclareMathOperator{\ht}{ht}$Here's an algorithm and associated formulas, under the assumptions that the two triangles have non-empty interior, i.e., non-collinear vertices; no vertex of either triangle lies in the plane of the other, particularly, the triangles are not coplanar; and the triangles either are disjoint or their interiors intersect. The parenthetical notes below indicate how these assumptions affect the logic of the algorithm.
If $p = (p_{x}, p_{y}, p_{z})$ and $q = (q_{x}, q_{y}, q_{z})$ are vectors, their dot and cross products are given by the formulas
$$
p \cdot q = p_{x} q_{x} + p_{y} q_{y} + p_{z} q_{z},\qquad
p \times q = (p_{y} q_{z} - p_{z} q_{y}, p_{z} q_{x} - p_{x} q_{z}, p_{x} q_{y} - p_{y} q_{x}).
$$
Denote the triangles by $P$ and $Q$, their respective vertices by $p_{1}$, $p_{2}$, $p_{3}$ and $q_{1}$, $q_{2}$, $q_{3}$, and let
$$
n_{P} = (p_{2} - p_{1}) \times (p_{3} - p_{1}),\qquad
n_{Q} = (q_{2} - q_{1}) \times (q_{3} - q_{1})
$$
be the respective normal vectors to the planes containing the triangles.
(Note: We're assuming these vectors are non-zero, i.e., that neither triangle has collinear vertices.)
Calculate the "heights"
$$
\ht(p_{1}) = n_{Q} \cdot (p_{1} - q_{1}),\qquad
\ht(p_{2}) = n_{Q} \cdot (p_{2} - q_{1}),\qquad
\ht(p_{3}) = n_{Q} \cdot (p_{3} - q_{1})
$$
of the vertices $p_{i}$ with respect to the plane containing the $q_{i}$. If these three numbers are all positive or all negative, the triangles do not intersect (because $P$ does not cross the plane containing $Q$). If at least one is positive and one is negative, calculate the "heights"
$$
\ht(q_{1}) = n_{P} \cdot (q_{1} - p_{1}),\qquad
\ht(q_{2}) = n_{P} \cdot (q_{2} - p_{1}),\qquad
\ht(q_{3}) = n_{P} \cdot (q_{3} - p_{1})
$$
of the vertices $q_{i}$ with respect to the plane containing the $p_{i}$. If these three numbers are all positive or all negative, the triangles do not intersect (because $Q$ does not cross the plane containing $P$).
(Notes: If the "height" of a vertex is zero, that vertex lies in the plane of the other triangle. If all three vertices of one triangle have height zero, the triangles are coplanar; if exactly two vertices have "height" zero, that triangle has an edge lying in the plane of the other triangle; if exactly one vertex has height zero, that triangle either touches the plane of the other triangle at one point, or else crosses the plane of the other triangle. In each case, a separate intersection test is required.)
Assume from now on that each triangle crosses the plane containing the other, i.e., that two of the numbers $\ht(p_{1})$, $\ht(p_{2})$, $\ht(p_{3})$ have the same sign and the third has opposite sign, and similarly for $\ht(q_{1})$, $\ht(q_{2})$, $\ht(q_{3})$. Suppose for definiteness that $\ht(p_{1})$ has opposite sign to $\ht(p_{2})$ and $\ht(p_{3})$, and that $\ht(q_{1})$ has opposite sign to $\ht(q_{2})$ and $\ht(q_{3})$.
The planes of the triangles intersect in a line $\ell$ (because we're assuming non-coplanar triangles), and the four points
$$
p_{1j} = p_{1} + \frac{\ht(p_{1})}{\ht(p_{1}) - \ht(p_{j})}(p_{j} - p_{1}),\qquad
q_{1j} = q_{1} + \frac{\ht(q_{1})}{\ht(q_{1}) - \ht(q_{j})}(q_{j} - q_{1})\quad
j = 2, 3,
$$
lie on $\ell$. Since $\ell$ has unit direction vector
$$
v = \frac{n_{P} \times n_{Q}}{\|n_{P} \times n_{Q}\|},
$$
each point $x$ of $\ell$ may be written uniquely as $x = p_{12} + (tx)v$, with the scalar $tx$ defined by
$$
tx = (x - p_{12}) \cdot v.
$$
Clearly $tp_{12} = 0$; calculate the scalars
$$
tp_{13} = (p_{13} - p_{12}) \cdot v,\qquad
tq_{12} = (q_{12} - p_{12}) \cdot v,\qquad
tq_{13} = (q_{13} - p_{12}) \cdot v,
$$
and form the real intervals
$$
I_{P} = [pa, pb] = \bigl[\min(0, tp_{13}), \max(0, tp_{13})\bigr],\qquad
I_{Q} = [qa, qb] = \bigl[\min(tq_{12}, tq_{13}), \max(tq_{12}, tq_{13})\bigr].
$$
The triangles $P$ and $Q$ intersect if and only if the intervals $I_{P}$ and $I_{Q}$ intersect, if and only if $\max(pa, qa) < \min(pb, qb)$, in which case the intersection is the interval
$$
[a, b] = \bigl[\max(pa, qa), \min(pb, qb)\bigr],
$$
and the triangles themselves intersect in the interval with endpoints
$$
p_{12} + av,\qquad
p_{12} + bv.
$$