Created
September 1, 2015 02:42
-
-
Save junfenglx/ac305184db62153b7734 to your computer and use it in GitHub Desktop.
Revisions
-
junfeng_hu created this gist
Sep 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # coding: utf-8 cache = dict() def f(n): if n <= 0: return 0 prev = cache.get(n-1) if not prev: s = 1; for i in range(1, n+1): s *= i cache[n] = s else: s = n * prev return s def trail0(n): count = 0 while n: r = n % 10 if r: break count += 1 n //= 10 return count l = lambda x:trail0(f(x)) print(trail0(f(30))) print(l(40))