# Split given isosceles triangle of height H into N equal parts

Given an integer **N** and an isosceles triangle consisting of height **H**, the task is to find **(N – 1)** points on the triangle such that the line passing through these points and parallel to the base of the triangle, divide the total area into **N** equal parts.

**Examples:**

Input:N = 3, H = 2Output:1.15 1.63Explanation:Make cuts at point 1.15 and 1.63 as shown below:

Input:N = 2, H = 1000Output:70710.67

**Approach:** The problem can be solved by observing the following properties:

Divide the triangle such that

(x_{i}/ h)^{2}= i / N

=>x_{i }= h*âˆš(i/n)

x_{i}= height of i^{th}cut from the top vertex of the triangle

Follow the steps below to solve the problem:

- Iterate over the range
**[1, N – 1]**. - In every
**i**iteration, print the value of^{th}**x**using the above formula._{i}

Below is the implementation of the above approach:

## C++

`// C++ Code for above approach` `#include <bits/stdc++.h>` `using` `namespace` `std;` `// Function to divide the isosceles triangle` `// in equal parts by making N-1 cuts` `// parallel to the base` `void` `findPoint(` `int` `n, ` `int` `h)` `{` ` ` ` ` `// Iterate over the range [1, n - 1]` ` ` `for` `(` `int` `i = 1; i < n; i++)` ` ` `printf` `(` `"%.2f "` `, ` `sqrt` `(i / (n*1.0)) * h);` `}` `// Driver code` `int` `main()` `{` ` ` `// Given N` ` ` `int` `n = 3;` ` ` `// Given H` ` ` `int` `h = 2;` ` ` `// Function call` ` ` `findPoint(n, h);` ` ` `return` `0;` `}` `// This code is contributed by mohit kumar 29` |

## Java

`// Java Code for above approach` `import` `java.util.*;` `class` `GFG` `{` ` ` `// Function to divide the isosceles triangle` ` ` `// in equal parts by making N-1 cuts` ` ` `// parallel to the base` ` ` `static` `void` `findPoint(` `int` `n, ` `int` `h)` ` ` `{` ` ` `// Iterate over the range [1, n - 1]` ` ` `for` `(` `int` `i = ` `1` `; i < n; i++)` ` ` `System.out.printf(` `"%.2f "` `,` ` ` `Math.sqrt(i / (n * ` `1.0` `)) * h);` ` ` `}` ` ` `// Driver code` ` ` `public` `static` `void` `main(String[] args)` ` ` `{` ` ` ` ` `// Given N` ` ` `int` `n = ` `3` `;` ` ` `// Given H` ` ` `int` `h = ` `2` `;` ` ` `// Function call` ` ` `findPoint(n, h);` ` ` `}` `}` `// This code is contributed by shikhasingrajput` |

## Python3

`# Python Code for above approach` `# Function to divide the isosceles triangle` `# in equal parts by making N-1 cuts` `# parallel to the base` `def` `findPoint(n, h):` ` ` `# Iterate over the range [1, n - 1]` ` ` `for` `i ` `in` `range` `(` `1` `, n):` ` ` `print` `(` `"{0:.2f}"` `.` `format` `(((i ` `/` `n) ` `*` `*` `0.5` `) ` `*` `h), end ` `=` `' '` `)` `# Driver Code` `if` `__name__ ` `=` `=` `'__main__'` `:` ` ` `# Given N` ` ` `n ` `=` `3` ` ` `# Given H` ` ` `h ` `=` `2` ` ` `# Function call` ` ` `findPoint(n, h)` |

## C#

`// C# Code for above approach` `using` `System;` `class` `GFG` `{` ` ` `// Function to divide the isosceles triangle` ` ` `// in equal parts by making N-1 cuts` ` ` `// parallel to the base` ` ` `static` `void` `findPoint(` `int` `n, ` `int` `h)` ` ` `{` ` ` `// Iterate over the range [1, n - 1]` ` ` `for` `(` `int` `i = 1; i < n; i++)` ` ` `Console.Write(` `"{0:F2} "` `,` ` ` `Math.Sqrt(i / (n * 1.0)) * h);` ` ` `}` ` ` `// Driver code` ` ` `public` `static` `void` `Main(String[] args)` ` ` `{` ` ` `// Given N` ` ` `int` `n = 3;` ` ` `// Given H` ` ` `int` `h = 2;` ` ` `// Function call` ` ` `findPoint(n, h);` ` ` `}` `}` `// This code is contributed by shikhasingrajput` |

## Javascript

`<script>` `// Javascript program for the above approach` ` ` `// Function to divide the isosceles triangle` ` ` `// in equal parts by making N-1 cuts` ` ` `// parallel to the base` ` ` `function` `findPolet(n, h)` ` ` `{` ` ` ` ` `// Iterate over the range [1, n - 1]` ` ` `for` `(let i = 1; i < n; i++)` ` ` `document.write(` ` ` `Math.sqrt(i / (n * 1.0)) * h + ` `" "` `);` ` ` `}` ` ` `// driver function` ` ` `// Given N` ` ` `let n = 3;` ` ` ` ` `// Given H` ` ` `let h = 2;` ` ` ` ` `// Function call` ` ` `findPolet(n, h);;` ` ` ` ` `// This code is contributed by souravghosh0416.` `</script> ` |

**Output:**

1.15 1.63

**Time Complexity:** O(N)**Auxiliary Space:** O(1)