Skip to content

Commit

Permalink
add solutions for Factorial-Trailing-Zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
xcv58 committed Dec 30, 2014
1 parent 9f337c8 commit 0d574c8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Factorial-Trailing-Zeroes/Solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public:
int trailingZeroes(int n) {
return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5);
}
};

int main(int argc, char *argv[]) {
return 0;
}
5 changes: 5 additions & 0 deletions Factorial-Trailing-Zeroes/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Solution {
public int trailingZeroes(int n) {
return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5);
}
}
4 changes: 4 additions & 0 deletions Factorial-Trailing-Zeroes/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Solution:
# @return an integer
def trailingZeroes(self, n):
return 0 if n == 0 else n / 5 + self.trailingZeroes(n / 5)

0 comments on commit 0d574c8

Please sign in to comment.