Nathan Harmston wrote:
> Unfortunately this doesnt work since a,a1,b,b1 arent declared in the
> function. Is there a way to make these variables accessible to the
> euclid function. Or is there a better way to design this function?
The canonical recommendations are: use attributes of the inner
fun
James Stroud wrote:
> Nathan Harmston wrote:
> def exteuclid(m,n):
> x = 0,1,1,0,m,n
> def euclid(c,d,x=x):
>a,a1,b,b1,c,d = x
>q = c /d
>r = c % d
>if r == 0:
>print a,b
>return d
>else:
>print a1,a,b1,b,c,d,q,r
>
Nathan Harmston wrote:
> Hi,
>
> I m playing around with extended euclids algorithm from Knuth. I m
> trying to build a function with a function inside it.
>
> def exteuclid(m,n):
> a,a1,b,b1,c,d = 0,1,1,0,m,n
> def euclid(c,d):
>q = c /d
>r = c % d
>if r == 0:
>
On Sun, 24 Jun, 7stud wrote:
> ef outer():
> a = 10
> def inner():
> print a
>
> return inner
>
>
> f = outer()
> f()
>
> --output:--
> 10
>
>>> def outer():
... a = 10
... def inner():
... a = a + 1
... print a
... return inner
...
>>> f=oute
On Jun 24, 11:55 am, "Nathan Harmston" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I m playing around with extended euclids algorithm from Knuth. I m
> trying to build a function with a function inside it.
>
> def exteuclid(m,n):
> a,a1,b,b1,c,d = 0,1,1,0,m,n
> def euclid(c,d):
> q = c /d
>
Nathan Harmston wrote:
> Hi,
>
> I m playing around with extended euclids algorithm from Knuth. I m
> trying to build a function with a function inside it.
>
> def exteuclid(m,n):
> a,a1,b,b1,c,d = 0,1,1,0,m,n
> def euclid(c,d):
>q = c /d
>r = c % d
>if r == 0:
>
Hi,
I m playing around with extended euclids algorithm from Knuth. I m
trying to build a function with a function inside it.
def exteuclid(m,n):
a,a1,b,b1,c,d = 0,1,1,0,m,n
def euclid(c,d):
q = c /d
r = c % d
if r == 0:
print a,b
return d