All pastes #2066435 Raw Edit

ccd

public text v1 · immutable
#2066435 ·published 2011-05-22 02:06 UTC
rendered paste body
#!/usr/bin/python

import sympy

def tokenize_node(a,b): #a GCD(a,b) funcion that remembers the multipliers along each step
        token_list=[]
        while a:
                a, b = b%a, a
                try:
                        token_list.append(int(b/a))
                except:
                        note="division by zero on last try is normal"
        return token_list


token_list=tokenize_node(4913,1594)


x=sympy.symbols('x')
frac=x

print token_list

token_list.reverse()

for token in token_list:
        frac=(token+(1/frac))

print frac

print sympy.simplify(frac)
print sympy.cancel(frac)