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); } }

27th May 2022, 4:27 PM
Yahaya Abubakar
Yahaya Abubakar - avatar
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); }
27th May 2022, 4:34 PM
A͢J
A͢J - avatar
+ 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); }
27th May 2022, 4:35 PM
A͢J
A͢J - avatar
+ 1
Thank you bro
27th May 2022, 4:40 PM
Yahaya Abubakar
Yahaya Abubakar - avatar