Spocoman

10. The Pyramid Of King Djoser

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