Leetcode之PHP版题目解析(172. Factorial Trailing Zeroes)


2019-3-26   


office web apps,(),officeexecl,word,ppt,,.(线blog)


 Leetcode之PHP版题目解析(169. Majority Element)

847f5f3d7321f63d71ee34bb694f9199.png


nn


0,0,5,!5,15,!10,.5.

    /**
     * @param Integer $n
     * @return Integer
     */
    function trailingZeroes($n) {
        $res=0;
        while($n){
            $res +=intval($n/5);
            $n /=5;  //5
        }
        return $res;
    }

,.

    /**
     * @param Integer $n
     * @return Integer
     */
    function trailingZeroes($n) {
        return   $n==0?0:intval($n/5)+$this->trailingZeroes($n/5);
    }


Github整理地址:https://github.com/wuqinqiang/leetcode-php

b995b610c9c504d90dd56c6c6ffd8792.png


Vote Vote Cancel Collect Collect Cancel

<< 上一篇: Leetcode PHP题解--D15 509. Fibonacci Number

>> 下一篇: Leetcode No.268 Missing Number(缺失数字)