Skip to content

Commit

Permalink
add euler57 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Nov 28, 2021
1 parent e255a85 commit e848416
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions euler0XX/euler057.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from fractions import Fraction


def continued_fractions(a0, an):
frac = Fraction(0)
for ai in reversed(an):
frac = Fraction(1, ai + frac)
yield a0 + frac


count = 0
for f in continued_fractions(1, [2] * 1000):
if len(str(f.numerator)) > len(str(f.denominator)):
count = count + 1

print(count)

0 comments on commit e848416

Please sign in to comment.