Advertisement
Guest User

Untitled

a guest
Jan 25th, 2019
1,590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  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. row++;
  24. let gold=currentbase*currentbase;
  25.  
  26. stone = Math.ceil(totalstone * increment);
  27. marble = Math.ceil(totalmarble * increment);
  28. lapis = Math.ceil(totallapis * increment);
  29. totalgold = Math.ceil(gold * increment);
  30. totalHeight = Math.floor(row*increment);
  31.  
  32. console.log(`Stone required: ${stone}`);
  33. console.log(`Marble required: ${marble}`);
  34. console.log(`Lapis Lazuli required: ${lapis}`);
  35. console.log(`Gold required: ${totalgold}`);
  36. console.log(`Final pyramid height: ${totalHeight}`);
  37.  
  38. }
  39. Pyramid(11,0.75)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement