Advertisement
dabidabidesh

thePyramidOfKingDjoser

May 19th, 2020
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //10. The Pyramid Of King Djoser
  2. function thePyramidOfKingDjoser(base, increment) {
  3.   'use strict'
  4.  
  5.   let stone = 0
  6.   let marble = 0
  7.   let lapisLazuli = 0
  8.   let gold = 0
  9.   let height = 0
  10.   for (let i = base, j = 1; i > 0; i -= 2, j++) {
  11.     height++
  12.     if (i === 1 || i === 2) {
  13.       gold += i * increment * i
  14.     } else {
  15.       stone += ((i - 2) * (i - 2)) * increment
  16.       if (j % 5 === 0)
  17.         lapisLazuli += (i * 2 + (i - 2) * 2) * increment
  18.       else
  19.         marble += (i * 2 + (i - 2) * 2) * increment
  20.     }
  21.   }
  22.   console.log(`Stone required: ${Math.ceil(stone)}`)
  23.   console.log(`Marble required: ${Math.ceil(marble)}`)
  24.   console.log(`Lapis Lazuli required: ${Math.ceil(lapisLazuli)}`)
  25.   console.log(`Gold required: ${Math.ceil(gold)}`)
  26.   console.log(`Final pyramid height: ${~~(height * increment)}`)
  27. }
  28. thePyramidOfKingDjoser(11,
  29.   0.75)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement