# Question:How to use recursion in Maple

## Question:How to use recursion in Maple

Maple 2016

I was trying to write a procedure that would compute a simple linear equation using the Extended Euclidean Algorithm. I was thinking of a procedure like the following:

``````solveEeaMatrix := proc (a::list, b::list)
local c::list;
c := a -iquo(a[1],b[1])*b;
print(c);
while (c[1] <> gcd(a[1],b[1]) do
...
``````

I am basically stuck at this part as

1) I don't know how to setup a multi-dimensional array that could dynamically grow(as a possible solution).

2) I can't come up with a recursive function that could possibly take care of this.

In short, if I am given for example an equation like: `84*x+203*y = 14`

I will transform it into 2 linear equation as follow:
`row0 := [203, 0, 1] row1 := [84, 1, 0] `Subsequently, I will perform the following:

``````c := a -iquo(a[1],b[1])*b;
``````

Where `a`and `b` are both lists and arguments of the procedure and `c`being another list and a local variable.

But I don't know how to do the following programmatically:

``````row3 := row1-iquo(row1[1], row2[1])*row2;
row4 := row2-iquo(row2[1], row3[1])*row3;
row5 := row3-iquo(row3[1], row4[1])*row4;
and so on ...
``````

Any hint would be appreciated.

﻿