Given $N$ Integers $A_1,A_2....A_N$, and a function $$F(i,j)=A_i*A_j mod P$$
$P =599*601$ both of which are prime.
I need to find out the number of integer 4-tuples $(a, b, c, d)$ there are such that $F(a, b), F(c, d)$ are co-prime and $ 1 ≤ a, b, c, d ≤ N$
I can only think of checking every pair of integers i.e brute force. Is there any way better than this ?
This answer is for the original version of the question. Some VBA for initial brute force attempt below using N = 1000. This been ran once on a laptop, and took > 15 mins to get to over 4 million for counttuples before process was stopped.
It is expected to take a significant time to run since requires at least $N^2$ calculations - eg probably a few hours for $N=1000$
Main sub:
Next a
Answer1=Msgbox ("Number of tuples is " & Count_tuples & " for " & N & " integers, for Prime1="&Prime1 & " and Prime2 = " & Prime2)
End Sub