Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Background: Imagine we are building stairs out of small bricks. For the first step, we use one brick. For the second step, we stack 2
Background: Imagine we are building stairs out of small bricks. For the first step, we use one brick. For the second step, we stack bricks. And for the third step, we stack bricks. And so on
With this in mind, write the function numberOfBrickssteps which takes a nonnegative integer number of steps, and returns the number of bricks that are required to create that many steps.
For example numberOfBricks returns which is
Hint: The sum from to n is called the nth triangular number. Here is a helpful formula to calculate the nth triangular number:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started