From 84cc19931b02f64acb9cedbc81b8fe54607a6a86 Mon Sep 17 00:00:00 2001 From: zhaocchen Date: Thu, 1 Jul 2021 15:45:13 +0800 Subject: [PATCH] feat: add typescript solution to lc problem: No.0172.Factorial Trailing Zeroes --- .../0172.Factorial Trailing Zeroes/README.md | 15 +++++++++++++++ .../0172.Factorial Trailing Zeroes/README_EN.md | 13 +++++++++++++ .../0172.Factorial Trailing Zeroes/Solution.ts | 8 ++++++++ 3 files changed, 36 insertions(+) create mode 100644 solution/0100-0199/0172.Factorial Trailing Zeroes/Solution.ts diff --git a/solution/0100-0199/0172.Factorial Trailing Zeroes/README.md b/solution/0100-0199/0172.Factorial Trailing Zeroes/README.md index 031f588d4f221..afa8677fc93c9 100644 --- a/solution/0100-0199/0172.Factorial Trailing Zeroes/README.md +++ b/solution/0100-0199/0172.Factorial Trailing Zeroes/README.md @@ -27,6 +27,8 @@ +统计5的个数 + ### **Python3** @@ -45,6 +47,19 @@ ``` +### **TypeScript** + +```ts +function trailingZeroes(n: number): number { + let count = 0; + while (n > 0) { + n = Math.floor(n / 5); + count += n; + } + return count; +}; +``` + ### **...** ``` diff --git a/solution/0100-0199/0172.Factorial Trailing Zeroes/README_EN.md b/solution/0100-0199/0172.Factorial Trailing Zeroes/README_EN.md index 96ec8ade640e0..fb40dcf0b8faf 100644 --- a/solution/0100-0199/0172.Factorial Trailing Zeroes/README_EN.md +++ b/solution/0100-0199/0172.Factorial Trailing Zeroes/README_EN.md @@ -56,6 +56,19 @@ ``` +### **TypeScript** + +```ts +function trailingZeroes(n: number): number { + let count = 0; + while (n > 0) { + n = Math.floor(n / 5); + count += n; + } + return count; +}; +``` + ### **...** ``` diff --git a/solution/0100-0199/0172.Factorial Trailing Zeroes/Solution.ts b/solution/0100-0199/0172.Factorial Trailing Zeroes/Solution.ts new file mode 100644 index 0000000000000..ddb0043efa6e1 --- /dev/null +++ b/solution/0100-0199/0172.Factorial Trailing Zeroes/Solution.ts @@ -0,0 +1,8 @@ +function trailingZeroes(n: number): number { + let count = 0; + while (n > 0) { + n = Math.floor(n / 5); + count += n; + } + return count; +}; \ No newline at end of file