# Get missing cyclic numbers via modulus?

Consider a list of numbers:

list = {1,2,3,4,5};


Taking a random set of three of these numbers:

{n1, n2, n3} = RandomSample[list, 3] // Sort


{1, 3, 4}

I would like to determine general coefficients a1,a2,a3 and b1,b2,b3:

n4 = Mod[a1 n1 + a2 n2 + a3 n3 , 5, 1] ;
n5 = Mod[b1 n1 + b2 n2 + b3 n3 , 5, 1] ;


such that n4 and n5 are set to the remaining two numbers, not appearing in {n1, n2, n3}, in increasing order. So, for the example above we should have:

{n4, n5}


{2, 5}

Is there a way to use Mathematica to solve for the unknowns a1,a2,a3 and b1,b2,b3, or determine if no such solution exists? Thanks for any suggestion!

• For your example, you could do FindInstance[{a1 + 3 a2 + 4 a3 == 2, b1 + 3 b2 + 4 b3 == 5}, {a1, a2, a3, b1, b2, b3}, Modulus -> 5] – Carl Woll Jun 17 '17 at 3:32
• @CarlWoll Yes, but my problem is that I need a closed form solution. By brute forcing I just noticed that no solution seems to exist in a sensible range of coefficient values. Trying to add more coefficients and higher powers of ni now. – Kagaratsch Jun 17 '17 at 3:36

su = Subsets[Range, {3}]; 