btw 樓主呢題 factorial
一個 for loop O(n) 已經搞掂啦
上面用兩個果班
我俾個 n = 1000000 你點行?
算子代數2020-11-19 15:21:53
題目幅圖睇唔到?
Cyborgman2020-11-19 16:04:35
Doesn't work if n == 0.
Also this has an unnecessary time complexity of O(n^2) when you can do it in O(n) by simply moving x outside the first loop and append the result of x*i.