Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pyramid(baza, stypka) {
- let base = parseFloat(baza);
- let increment = parseFloat(stypka);
- let stone = 0;
- let marble = 0;
- let lapisLazuli = 0;
- let gold = 0;
- let heigth = 0;
- for (let i = base, j = 1; i > 0; i -= 2, j++) {
- heigth++;
- if (i == 1 || i == 2) {
- (gold += i * i * increment)
- break;
- }
- let width = i;
- let length = i;
- stone += ((width - 2) * (length - 2)) * increment;
- if (j % 5 !== 0) {
- marble += ((i * 4) - 4) * increment;
- }
- if (j % 5 === 0) {
- lapisLazuli += ((4 * i) - 4) * increment;
- }
- }
- console.log(`Stone required: ${Math.ceil(stone)}`);
- console.log(`Marble required: ${Math.ceil(marble)}`)
- console.log(`Lapis Lazuli required: ${Math.ceil(lapisLazuli)}`);
- console.log(`Gold required: ${Math.ceil(gold)}`);
- console.log(`Final pyramid height: ${Math.floor(heigth*increment)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement