Advertisement
Spocoman

Three brothers

Oct 9th, 2023
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function threeBrothers(input) {
  2.     let firstTime = Number(input[0]);
  3.     let secondTime = Number(input[1]);
  4.     let thirdTime = Number(input[2]);
  5.     let fatherTime = Number(input[3]);
  6.  
  7.     let cleaningTime = 1 / (1 / firstTime + 1 / secondTime + 1 / thirdTime) * 1.15;
  8.  
  9.     console.log(`Cleaning time: ${cleaningTime.toFixed(2)}`);
  10.     if (fatherTime > cleaningTime) {
  11.         console.log(`Yes, there is a surprise - time left -> ${Math.floor(fatherTime - cleaningTime)} hours.`);
  12.     } else {
  13.         console.log(`No, there isn't a surprise - shortage of time -> ${Math.ceil(cleaningTime - fatherTime)} hours.`);
  14.    }
  15.    return;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement