I Hope this is useful.

]]>
1 2 3 4 5 6 7 |
for m in count(1): for a in range(m): rts = tuple(filter(lambda x: x**2 % m == a, range(m))) # brute force rtx = sqrt_mod_m(a, m) if rts != rtx: print(a, m, rts, rtx) |

Thanks again. I still want to dig through and understand how it works. I’m still a number theory newbie.

Rick

]]>\[{gcd}(a_1, a_2, …, a_n) = 1\]

You can add a check by changing the last line in the frobenius_number function with the following:

1 2 3 4 5 6 |
if gcd(*a) == 1: return max(__residue_table(sorted(a))) - min(a) else: return None |

Alternatively add this before the last line:

1 2 3 4 |
if gcd(*a) > 1: raise ValueError |

I have been updating other parts of the library today so I have added this check as well.

]]>Here are a few examples of my program using your function:

d:dev>rpn [ 6 9 20 ] frobenius

43

d:dev>rpn [ 6 9 24 ] frobenius

3

d:dev>rpn [ 6 8 13 ] frobenius

23

d:dev>rpn [ 6 8 12 ] frobenius

10

I haven’t had a chance to go through the function to see if I can figure out why it does this. It will probably take me some time to understand it well enough, but I thought I would drop you a note.

p.s. I’m looking forward to implementing operators for some of the other functions as well.

Now I am off to McDonald’s to order 43 Chicken McNuggets!