Skip to content

Instantly share code, notes, and snippets.

@hueitan
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save hueitan/6eaad3406ca84d19ec28 to your computer and use it in GitHub Desktop.

Select an option

Save hueitan/6eaad3406ca84d19ec28 to your computer and use it in GitHub Desktop.

Revisions

  1. Huei Tan revised this gist May 28, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,12 @@ var zeroes = function z(n) {
    k = n/5 | 0
    return k ? k + f(k) : 0
    }
    // or
    function zeroes (n) {
    s = 0
    while (n/=5) s += n|0
    return s
    }
    ```

    79 char
  2. Huei Tan revised this gist May 27, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,12 @@ function zeroes(n) {
    }
    return result;
    }

    // alternative of zeroes
    var zeroes = function z(n) {
    k = n/5 | 0
    return k ? k + f(k) : 0
    }
    ```

    79 char
  3. Huei Tan revised this gist May 6, 2015. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -44,4 +44,17 @@ function superfactorialZeros(N) {

    return R
    }
    ```

    well... 71 cahr
    ```js
    function superfactorialZeros(N) {
    R = 0

    while (j = N--)
    while (j /= 5)
    R += j & j

    return R
    }
    ```
  4. Huei Tan revised this gist May 6, 2015. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -30,4 +30,18 @@ function superfactorialZeros(N) {

    return R
    }
    ```

    76 char
    ```js
    function superfactorialZeros(N) {
    R = 0

    while (n=N--)
    while(n>=5)
    R += (n/=5)|0


    return R
    }
    ```
  5. Huei Tan revised this gist May 6, 2015. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,17 @@ function zeroes(n) {
    }
    return result;
    }
    ```

    79 char
    ```js
    function superfactorialZeros(N) {
    R = 0

    for (; N ; N--)
    for (j = 5; N >= j; j *= 5)
    R += N / j | 0

    return R
    }
    ```
  6. Huei Tan created this gist May 6, 2015.
    20 changes: 20 additions & 0 deletions trailing_zero.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    ```js
    function superfactorialZeros(N) {
    var result = 0;
    for (i = 1; i <= N; i++) {
    result += zeroes(i);
    }

    return result;
    }

    function zeroes(n) {
    var i = 1;
    var result = 0;
    while (n >= i) {
    i *= 5;
    result += Math.floor(n / i);
    }
    return result;
    }
    ```