I have tried finding the general form but it appears that there is no general form. I could try just brute forcing it but it just is impractical.
PS: please only use the following theorems:
- Division Algorithm
- Bezout's Theorem
- Euclidean Algorithm
- Euclid Lemma
- Fundamental Theorem of Arithmetic