Advertisement
dimoBs

10. The Pyramid Of King Djoser

Nov 3rd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      function Pyramid(base, increment) {
  2.  
  3.          let totalstone = 0;
  4.          let totalmarble = 0;
  5.          let totallapis = 0;
  6.          let totalgold = 0;
  7.          let row = 0;
  8.          let currentbase = base;
  9.  
  10.          while (currentbase > 2) {
  11.              let marbel = currentbase * 4 - 4;
  12.              let stone = currentbase * currentbase - marbel;
  13.              totalstone += stone;
  14.  
  15.              row++;
  16.              if (row % 5 === 0) {
  17.                  totallapis += marbel;
  18.              } else {
  19.                  totalmarble += marbel;
  20.              }
  21.              currentbase -= 2;
  22.          }
  23.  
  24.  
  25.          row++;
  26.          let gold = currentbase * currentbase;
  27.  
  28.          stone = Math.ceil(totalstone * increment);
  29.          marble = Math.ceil(totalmarble * increment);
  30.          lapis = Math.ceil(totallapis * increment);
  31.          totalgold = Math.ceil(gold * increment);
  32.          totalHeight = Math.floor(row * increment);
  33.  
  34.          console.log(`Stone required: ${stone}`);
  35.          console.log(`Marble required: ${marble}`);
  36.          console.log(`Lapis Lazuli required: ${lapis}`);
  37.          console.log(`Gold required: ${totalgold}`);
  38.          console.log(`Final pyramid height: ${totalHeight}`);
  39.  
  40.      }
  41.  
  42.      Pyramid(23,
  43.          0.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement