Permalink
Browse files

problem 74

  • Loading branch information...
1 parent 52e1734 commit 45f93f031c29ab205d3b13e1cbdf758bbab0aa12 @tingleshao committed Mar 28, 2013
Showing with 53 additions and 1 deletion.
  1. +1 −1 problem71to80/problem73.py
  2. +52 −0 problem71to80/problem74.py
@@ -12,7 +12,7 @@ def gcd(a,b):
#count = 0
for d in range(1,12001):
print d
- for n in range(1,d):
+ for n in range((d-1)/3,(d+1)/2):
fn = float(n)
flag = True
if fn / d >= 1.0 / 2:
View
@@ -0,0 +1,52 @@
+# problem 74
+def factorial(n):
+ if n == 0:
+ return 1
+ elif n == 1:
+ return 1
+ elif n == 2:
+ return 2
+ elif n == 3:
+ return 6
+ elif n == 4:
+ return 24
+ elif n == 5:
+ return 120
+ elif n == 6:
+ return 720
+ elif n == 7:
+ return 5040
+ elif n == 8:
+ return 40320
+ elif n == 9:
+ return 362880
+len_lst = []
+total_count = 0
+for i in range(1,1000000):
+ print "-----------"
+ print i
+ dd = i
+ sum_ = 0
+ lst = []
+ while True:
+ sum_ = 0
+ for d in str(dd):
+ sum_ = sum_ + factorial(int(d))
+ if sum_ in lst:
+ len_lst.append(len(lst))
+ if i == 78:
+ print "--------"
+ print lst
+ print "88888"
+ if len(lst) == 59:
+ total_count += 1
+ print "-->>>>>" + str(i)
+ break
+ lst.append(sum_)
+ dd = sum_
+print total_count
+
+print "max: " +str( max(len_lst) )
+
+
+

0 comments on commit 45f93f0

Please sign in to comment.