Here comes a sage code for computing the unit fraction representation of any fraction less than 1. For details about the algorithm see my previous blog entry.
def find_d(a, b):
"""find an appropriate unit fraction"""
d=1
while 1/d>a/b:
d+=1
return d
#input numerator and denominator separately
a=raw_input("Please insert numerator:")
b=raw_input("Please insert denominator:")
a=float(a)
b=float(b)
print "Unit fraction representation of %i/%i"%(a,b)
d=find_d(a,b)
print "1: ", 1/d #first unit fraction
i=2
while (a*d-b <> 1) & (a*d-b <> 0) :
a=a*d-b
b=b*d
d=find_d(a,b)
print "%i: "%i, 1/d
i+=1
#last unit fraction
if (a*d-b <> 0) :
print "%i: %i/%i"%(i,(a*d-b),(b*d))