- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

# C/C++ Program for Number of solutions to Modular Equations?

We have an n number of coins and we have to French the coin way that it makeup Pyramid of maximum height. We will arrange the first coin in First row second and third coin in the second row and so on

In the given diagram, we make pyramid 6 of coins having a height of 3. We cannot make height 4 but we will need 10 coins. It is simple to get the height by using this formula;

H = {(-1+ √(1+8N))/2}

Input: n = 10 Output: Height of pyramid: 4

## Explanation

Height by using this formula

H = {(-1+ √(1+8N))/2}

## Example

#include <iostream> #include <math.h> using namespace std; int main() { int n=10; int height = (-1 + sqrt(1 + 8 * n)) / 2; cout << "Height of pyramid: " <<height; }

- Related Questions & Answers
- Program for Number of solutions to Modular Equations in C/C++?
- C/C++ Program for Number of solutions to the Modular Equations?
- Find the Number of Solution to Modular Equations using C++
- Program to find number of solutions for given equations with four parameters in Python
- Program to find number of solutions in Quadratic Equation in C++
- C++ Program to Implement Modular Exponentiation Algorithm
- Python program for Modular Exponentiation
- Find the number of solutions to the given equation in C++
- Number of non-negative integral solutions of sum equation in C++
- Satisfiability of Equality Equations in C++
- Find the Number of solutions for the equation x + y + z <= n using C++
- C++ Program to Represent Linear Equations in Matrix Form
- Find the Number of Solutions of n = x + n x using C++
- C/C++ Program for Triangular Matchstick Number?
- C/C++ Program for nth Catalan Number?

Advertisements