一、定义函数的方式 1.函数声明:function abc(){} 2.函数表达式:var abc = function(){} 二、递归 1.通过自身的名字调用:但函数名赋值给其他函数时失效 function factorial(num){ if (num <= 1){ return 1; } e ...
分类:
其他好文 时间:
2016-06-14 23:42:36
阅读次数:
194
Factorial称之为阶乘,维基百科是这样描述的“一个正整数的阶乘是所有小于及等于该数的正整数的积,并且有0的阶乘为1。自然数n的阶乘写作n!。” 而阶乘函数是递归(Haskell)函数典型示例。在JavaScript中可能运用到递归函数。但在实际使用中,你可能没有考虑何时何地递归是有用的,或者使 ...
分类:
编程语言 时间:
2016-06-03 12:50:47
阅读次数:
859
题目链接:https://leetcode.com/problems/factorial-trailing-zeroes/
题目:
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity....
分类:
其他好文 时间:
2016-06-02 13:46:54
阅读次数:
104
1028 - Trailing Zeroes (I) PDF (English) Statistics ForumTime Limit: 2 second(s) Memory Limit: 32 MBWe know what a base of a number is and what the pr ...
分类:
其他好文 时间:
2016-06-01 19:42:16
阅读次数:
254
http://lightoj.com/volume_showproblem.php?problem=1282 题目大意: 求n的k次方的前三位和后三位数然后输出 后三位是用快速幂做的,我刚开始还是不会快速幂,后来慢慢理解了。 前三位求得比较厉害 我们可以吧n^k = a.bc * 10.0^m; k ...
分类:
其他好文 时间:
2016-05-31 20:28:05
阅读次数:
139
https://jeffmo.github.io/es-trailing-function-commas 目前是一个 stage 3 的提案,Chakra 和 JSC 已经实现了,它允许我们在函数定义时的最后一个形参和函数调用时的最后一个实参的尾部加上逗号。 最后一个参数加上逗号有什么优点? 注意: ...
分类:
其他好文 时间:
2016-05-30 19:51:11
阅读次数:
289
1082 - Array Queries PDF (English) Statistics ForumTime Limit: 3 second(s) Memory Limit: 64 MBGiven an array with N elements, indexed from 1 to N. Now ...
分类:
其他好文 时间:
2016-05-29 21:16:57
阅读次数:
159
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 转:http://www.jianshu.com ...
分类:
其他好文 时间:
2016-05-23 22:46:07
阅读次数:
165