Advertisement
dabidabidesh

Untitled

May 24th, 2020
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pyramid(baza, stypka) {
  2.     let base = parseFloat(baza);
  3.     let increment = parseFloat(stypka);
  4.     let stone = 0;
  5.     let marble = 0;
  6.     let lapisLazuli = 0;
  7.     let gold = 0;
  8.     let heigth = 0;
  9.     for (let i = base, j = 1; i > 0; i -= 2, j++) {
  10.  
  11.         heigth++;
  12.         if (i == 1 || i == 2) {
  13.             (gold += i * i * increment)
  14.             break;
  15.         }
  16.         let width = i;
  17.         let length = i;
  18.         stone += ((width - 2) * (length - 2)) * increment;
  19.         if (j % 5 !== 0) {
  20.             marble += ((i * 4) - 4) * increment;
  21.         }
  22.         if (j % 5 === 0) {
  23.             lapisLazuli += ((4 * i) - 4) * increment;
  24.         }
  25.  
  26.     }
  27.     console.log(`Stone required: ${Math.ceil(stone)}`);
  28.     console.log(`Marble required: ${Math.ceil(marble)}`)
  29.     console.log(`Lapis Lazuli required: ${Math.ceil(lapisLazuli)}`);
  30.     console.log(`Gold required: ${Math.ceil(gold)}`);
  31.     console.log(`Final pyramid height: ${Math.floor(heigth*increment)}`);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement