Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //10. The Pyramid Of King Djoser
- function thePyramidOfKingDjoser(base, increment) {
- 'use strict'
- let stone = 0
- let marble = 0
- let lapisLazuli = 0
- let gold = 0
- let height = 0
- for (let i = base, j = 1; i > 0; i -= 2, j++) {
- height++
- if (i === 1 || i === 2) {
- gold += i * increment * i
- } else {
- stone += ((i - 2) * (i - 2)) * increment
- if (j % 5 === 0)
- lapisLazuli += (i * 2 + (i - 2) * 2) * increment
- else
- marble += (i * 2 + (i - 2) * 2) * 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: ${~~(height * increment)}`)
- }
- thePyramidOfKingDjoser(11,
- 0.75)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement