看板 java 關於我們 聯絡資訊
這幾天在練習java的loop可是老師出了x^n/n!,目前我只知道x^n/n而已。請問有什麼地 方可以做修改嗎? double sum(int x, int n) { double i, total = 1.0; for (i = 1; i <= n; i++) total = total + (pow(x, i) / i); return total; } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 172.56.42.86 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1539295958.A.FE2.html
pdz: 兩個迴圈 10/12 12:43
tedwu2001: 應該多一個變數記階乘就好,不用到兩層迴圈吧? 10/14 03:56