[問題] 關於x^n/n!

作者: cheng220 (David220)   2018-10-12 06:12:36
這幾天在練習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;
}
作者: pdz (披低)   2018-10-12 12:43:00
兩個迴圈
作者: tedwu2001   2018-10-14 03:56:00
應該多一個變數記階乘就好,不用到兩層迴圈吧?

Links booklink

Contact Us: admin [ a t ] ucptt.com