Liliana797979

piramid of king djoser - fundamentals

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