Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 java 中,哪种方法通常更快地计算数字的阶乘?递归还是迭代?
另外,哪个更适合较大的数字,哪个更适合较小的数字?
迭代总是更快!和储蓄者!并且占用更少的内存!
当您使用递归函数时,每一步都将在您的堆栈中直到结束,这可能会占用大量资源。