Permalink
Browse files

problem104

  • Loading branch information...
1 parent eef4e70 commit 75b774182346d8cd2bb66e1f6b4a610979520fc4 @tingleshao committed Jun 15, 2013
Showing with 35 additions and 0 deletions.
  1. +35 −0 problem101to110/problem104.py
View
35 problem101to110/problem104.py
@@ -0,0 +1,35 @@
+def fast_fibo(n):
+ return fast_fib_n(1,1,n)
+
+def fast_fib_n(a,b,n):
+ for i in xrange(n-1):
+ temp = b
+ b = a + b
+ a = temp
+ return a
+
+
+print fast_fibo(1)
+print fast_fibo(2)
+print fast_fibo(3)
+print fast_fibo(2000)
+
+start = fast_fibo(329466)
+start2 = fast_fibo(329467)
+for i in xrange(329466,329470):
+ new_fib = start
+ str_fib = str(new_fib)
+ first_nine_list = list(str_fib[0:9])
+ last_nine_list = list(str_fib[-9:])
+ first_nine_list.sort()
+ last_nine_list.sort()
+ first_nine = "".join(first_nine_list)
+ last_nine = "".join(last_nine_list)
+ print i
+ if first_nine == last_nine == "123456789":
+ print "=============="
+ print i
+ break
+ temp = start2
+ start2 = start+ start2
+ start = temp

0 comments on commit 75b7741

Please sign in to comment.