n久不做题了 ,之前因为考研,然后又是假期,一直懒得做,今天开始吧
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
开始没有看到是阶乘,之后又研究复杂度的问题
代码如下:
class Solution { public: int trailingZeroes(int n) { int count = 0; for (;n > 4;) { n = n / 5; count = count + n; } return count; } };
时间: 2024-12-21 03:55:59