-
幕布斯7119047
var sum = 0; for(var i = 0;i<=i;i++){ if(sum >= 100){ break; }else{ sum += i; } } console.log('i =' +(i-1)); //i = 14 console.log('sum = '+sum); //sum = 105
-
隔江千里
function a(count){ var sum =0; for(var i=1;i<count;i++){ if(sum >count){ console.log(i-1); break; } sum +=i; }}a(100);//求累加值刚好超过100,参数传100,求累加值刚好超过1000,参数传1000,
-
哈士奇WWW
var sum = 0;for (var i = 0; sum <= 100; i++) { sum += i;}console.log(sum);console.log(i-1);
-
杨__羊羊
function xx(){ var sum=0; var n=0; for(;;){ if(sum<=100){ n++; sum+=n; console.log(n); }else{ console.log(n); return n; } }}xx();
-
蝴蝶刀刀
var sum = 0;for (var i = 1; sum <= 100; i++) { sum += i;}console.log(sum);console.log(i);
-
猛跑小猪
var a=1;var sum=0;while(sum<=100){ a++; sum+=a;}console.log(sum);console.log(a);
-
Smart猫小萌
var n = 0; for(var i = 1; i<=100;i++){ if(n<=100){ n = i+n; console.log(n) //105 console.log(i); //14 } }
-
千巷猫影
function a(v) { for (let i = 0; i < i + 1; i++) { v -= i; if (v <= 0) { console.log(i - 1); break; } }}a(100);