choclate _ sum []

Run Settings
LanguageJavaScript
Language Version
Run Command
// //3 // function processData(input) { // n_choclates = Number(input) // total_choc = n_choclates //9 // rem_choc = Math.floor(n_choclates % 3 ) //0 // new_choc = Math.floor(n_choclates / 3) //3 // temp_choc = new_choc + rem_choc // //9 // // n_choclates = temp_choc // if (temp_choc < 3) // { // total_choc += temp_choc // } // while (temp_choc >= 3 ) { // total_choc += new_choc // n_choclates = temp_choc //3 // rem_choc = Math.floor(n_choclates % 3 ) //0 // new_choc = Math.floor(n_choclates / 3) // 1 // n_choclates += new_choc // 4 // total_choc += n_choclates // 13 // temp_choc = new_choc + rem_choc // } // console.log(total_choc); // } // process.stdin.resume(); // process.stdin.setEncoding("ascii"); // _input = ""; // process.stdin.on("data", function (input) { // _input += input; // }); // process.stdin.on("end", function () { // processData(_input); // }); //4 function processData(input) { n_choclates = Number(input) total_choc = n_choclates //7 rem_choc = Math.floor(n_choclates % 3 ) //1 new_choc = Math.floor(n_choclates / 3) //1 total_choc += new_choc //5 temp_choc = new_choc + rem_choc //2 while (temp_choc >= 3) { n_choclates = temp_choc //3 rem_choc = Math.floor(n_choclates % 3 ) //0 new_choc = Math.floor(n_choclates / 3) // 1 total_choc += new_choc // 10 temp_choc = new_choc + rem_choc } console.log(total_choc); } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
Editor Settings
Theme
Key bindings
Full width
Lines