summaryrefslogtreecommitdiff
path: root/057.py
diff options
context:
space:
mode:
Diffstat (limited to '057.py')
-rw-r--r--057.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/057.py b/057.py
new file mode 100644
index 0000000..8098995
--- /dev/null
+++ b/057.py
@@ -0,0 +1,16 @@
+
+def get_fraction(c):
+ (n, d) = (1, 2)
+ for i in xrange(1, c):
+ (n, d) = (2*d+n, d) # add 2
+ (n, d) = (d, n) # 1/x, swap entries
+ return (d+n, d) # add 1
+
+count = 0
+for i in xrange(1, 1000):
+ (n, d) = get_fraction(i)
+ if len(str(n)) > len(str(d)):
+ count += 1
+
+print count
+