Laël Cellier on Sun, 12 Jan 2025 12:53:35 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: What’s the equivalent of Mathematica’s Solve[] Function in Pari/Gp ? |
How can I get Pari/gp to automatically rewrite something like : ((25)^2 + x RSA260)/(y) == c Le 12/01/2025 à 11:58, Karim Belabas a écrit :
Hi Laël, Bill's question was about the algorithm used, not the result. To solve a*x + b*y = c in {x,y} integers (given a,b,c integers) in GP: Solve(a,b,c) = { my([u, v, d] = gcdext(a, b)); if (c % d, return ([])); \\ no solution my(x = c/d * u % (b/d)); [x, (c - a*x) / b]; } ? Solve(300001,4139891237,5) %1 = [1952821586, -141513] ? 1952821586 * 300001 - 141513*4139891237 %2 = 5 Cheers, K.B.