"""
continued fractions

>>> phi
1.6180371352785146

>>> pi
3.1415189855952756
"""

phi =\
(1 + 1/
    (1 + 1/
        (1 + 1/
            (1 + 1/
                (1 + 1/
                    (1 + 1/
                        (1 + 1/
                            (1 + 1/
                                (1 + 1/
                                    (1 + 1/
                                        (1 + 1/
                                            (1+ 1/
                                               (1 + 1)))))))))))))



pi =3 + \
(1**2/
    (6 + 3**2/
        (6 + 5**2/
            (6 + 7**2/
                 (6 + 9**2/
                     (6 + 11**2/
                         (6 + 13**2/
                             (6 + 15**2/
                                 (6 + 17**2/
                                     (6 + 19**2/
                                         (6 + 21**2/
                                             (6 + 23**2/
                                                 (6 + 25**2/
                                                     (6+ 27**2/
                                                         6))))))))))))))


def _test( ):
    import doctest
    doctest.testmod( )

if __name__ == "__main__":
    _test( )
_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to