function factorialize(num) {
var count = 1;
for (var i = 1; i < num; i++) {
count = count + (count * i);
}
return count;
}
factorialize(1);
为什么在使用1时会返回1?不应该返回2因为count = 1 +(1 * 1)?
答案 0 :(得分:0)
对于Intent goToHomeIntent = new Intent(Intent.ACTION_MAIN);
goToHomeIntent.addCategory(Intent.CATEGORY_HOME);
goToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(goToHomeIntent);
,当我们进入循环时,支票num = 1
返回false,因此我们无法进入i < num
并以count = 1转到count = count + (count * i);