0
Please who can help i try my best
function main() { var depth = parseInt(readLine(), 10); //your code goes here var depth =depth; var distance=0; var days=0; while(depth >=distance){ distance +=7; days++; if(depth >=distance){ break ; } distance -=2; console .log(days); } }
3 RĂ©ponses
+ 1
Yahaya Abubakar
Using for loop
//Please who can help i try my best
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
//var depth =depth;
var distance=0;
var days=0;
for(var i = 0; i < depth; i++) {
distance +=7;
days++;
if(distance >= depth){
break ;
}
distance -=2;
}
console.log(days);
}
+ 1
Yahaya Abubakar
Using while loop:
//Please who can help i try my best
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
//var depth =depth;
var distance=0;
var days=0;
while (depth >= distance) {
distance +=7;
days++;
if(distance >= depth){
break ;
}
distance -=2;
}
console.log(days);
}
+ 1
Thank you bro