Fori Mix wrote:I understand that the line "g, y, x = egcd(b % a, a)" gives value to 3 variables (g,y,x) with one return command. I don't know how to do this in java and my biggest problem is the recursion. How can i give values to g, y and x in java?
Actually, that isn't really what the Python code is doing - Python, like Java, only returns a single value. Unlike Java, Python will automatically 'unpack' certain data types (Tuples) when it detects commas on the left side of the assignment.
So what egcd(a,b) does is return a datatype called a Tuple. A Tuple is like an array - it is a fixed size sequence. The sequence is unpacked so that the variables g, y, and x get the zeroth, first, and second value in the returned Tuple.
The key point to recognize a Tuple is the presence of Commas, though they usually are surrounded by parenthesis as well. The code has this return value:
That is like saying this:
It is returning a Tuple of length 3 (a 3-tuple).