Joreto

Untitled

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