- Related Questions & Answers
- C/C++ Program for Maximum height when coins are arranged in a triangle?
- When are python objects candidates for garbage collection?
- Maximum path sum in a triangle in C++
- How to create a triangle using Python for loop?
- Minimum height of a triangle with given base and area in C++
- Maximum Perimeter Triangle from array in C++
- Write a Program to Find the Maximum Depth or Height of a Tree in C++
- C/C++ Program for Greedy Algorithm to find Minimum number of Coins
- Maximum sum of a path in a Right Number Triangle in C++
- Height Checker in Python
- Python program maximum of three.
- How objects are organized in a web document? How is it arranged in a hierarchy?
- Partition Array for Maximum Sum in Python
- Arranging Coins in C++
- Largest Perimeter Triangle in Python

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below.

**Problem statement** − We are given N coins where we need to arrange them in form of a triangle, i.e. in the first row will have 1 coin, the second row will have 2 coins and so on, we need to display the maximum height that can be achieved by the help N coins.

Now let’s observe the solution in the implementation below −

# squareroot def squareRoot(n): # initial approximation x = n y = 1 e = 0.000001 # allowed error while (x - y > e): x = (x + y) / 2 y = n/x return x # max height def find(N): # calculating portion of the square root n = 1 + 8*N maxH = (-1 + squareRoot(n)) / 2 return int(maxH) # main N = 17 print("Maximum height is :",find(N))

Maximum height is : 5

All the variables are declared in the local scope and their references are seen in the figure above.

In this article, we have learned about how we can make a Python Program for Maximum height when coins are arranged in a triangle.

Advertisements