MCPcopy Create free account
hub / github.com/ActiveState/code / fc2fr

Function fc2fr

recipes/Python/578936_Continous_Fractions/recipe-578936.py:15–23  ·  view source on GitHub ↗

Return a fraction from a continuos fraction fc0 [a1,a2,a3,...]

(fc0)

Source from the content-addressed store, hash-verified

13 return reduce(lambda x,y: y+(1.0/x),ff)
14
15def fc2fr(fc0):
16 "Return a fraction from a continuos fraction fc0 [a1,a2,a3,...]"
17 fc3=list(fc0)
18 a=fc3.pop()
19 b=1
20 fc3.reverse()
21 for k in fc3:
22 a,b=k*a+b,a
23 return [a,b]
24
25if __name__ == "__main__":
26

Callers 1

recipe-578936.pyFile · 0.85

Calls 3

listClass · 0.85
popMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected