The Leibniz harmonic triangle is a triangular arrangement of unit fractions in which the outermost diagonals consist of the reciprocals of the row numbers and each inner cell is the cell diagonally above and to the left minus the cell to the left. To put it algebraically, L(r, 1) = 1/r, where r is the number of the row, starting from 1, and c is the number, never more than r and L(r, c) = L(r – 1, c – 1) – L(r, c – 1)
Relation with pascal’s triangle
Whereas each entry in Pascal’s triangle is the sum of the two entries in the above row, each entry in the Leibniz triangle is the sum of the two entries in the row below it. For example, in the 5th row, the entry (1/30) is the sum of the two (1/60)s in the 6th row.
Just as Pascal’s triangle can be computed by using binomial coefficients, so can Leibniz’s:
If one takes the denominators of the nth row and adds them, then the result will equal n.2n-1. For example, for the 3rd row, we have 3 + 6 + 3 = 12 = 3 × 22.
Given a positive integer n. The task is to print Leibniz harmonic triangle of height n.
Input : n = 4 Output : 1 1/2 1/2 1/3 1/6 1/3 1/4 1/12 1/12 1/4 Input : n = 3 Output : 1 1/2 1/2 1/3 1/6 1/3
Below is the implementation of printing Leibniz harmonic triangle of height n based on above relation with Pascal triangle.
1/1 1/2 1/2 1/3 1/6 1/3 1/4 1/12 1/12 1/4
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program for harmonic mean of numbers
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Harmonic progression Sum
- Program to find the Nth Harmonic Number
- Harmonic Progression
- Program to find sum of harmonic series
- Summation of floor of harmonic progression
- Check whether nodes of Binary Tree form Arithmetic, Geometric or Harmonic Progression
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Program to print a Hollow Triangle inside a Triangle
- Check whether a given point lies inside a triangle or not
- Count Integral points inside a Triangle
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Possible to form a triangle from array values
- Find coordinates of the triangle given midpoint of each side
- Program to find area of a triangle
- C Program to print Floyd's triangle
- Find other two sides of a right angle triangle
- Check whether right angled triangle is valid or not for large sides
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.