Advertisement
angelstoev

Задача: умната Лили

Sep 2nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function smartLilly(args) {
  2.     let washMashine = Number(args[1]);
  3.     let priceGift = Number(args[2]);
  4.     let age = Number(args[0]);
  5.     let birthdayMoney = 0;
  6.     let gifts = 0;
  7.    let bonusMoney = 0;
  8. for (i = 1; i <= age; i+=2) {
  9.     bonusMoney += 10;
  10.     birthdayMoney += bonusMoney;
  11.     birthdayMoney--;
  12. }
  13. for (i = 0; i< age; i+=2) {
  14.     gifts++;
  15. }
  16. if(washMashine <= (birthdayMoney + (gifts * priceGift))){
  17.     console.log("Yes! " + (birthdayMoney + (gifts * priceGift) - washMashine).toFixed(2));
  18. }else if(washMashine > (birthdayMoney + (gifts * priceGift))){
  19.     console.log("No! " + (washMashine - (birthdayMoney + (gifts * priceGift))).toFixed(2));
  20. }
  21. }
  22. smartLilly([10, 170, 6]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement