Liliana797979

piramid of the djoser - fundamentals

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