# Integer part of the geometric mean of the divisors of N

Given an integer **N**, the task is to find the integer part of the geometric mean of the divisors of **N**. The **Geometric Mean** is a special type of average where we multiply the numbers together and then take a square root (for two numbers), cube root (for three numbers), and so on.

Examples:

Input:N = 4

Output:2

Divisors of 4 are 1, 2 and 4

Geometric mean = (1 * 2 * 4)^{(1/3)}= 8^{(1/3)}= 2

Input:N = 16

Output:8

Divisors of 16 are 1, 2, 4, 8 and 16

Geometric mean = (1 * 2 * 4 * 8 * 16)^{(1/5)}= 1024^{(1/5)}= 4

**Approach:** It cane be observed that a series will be formed for the values of **N** as **1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, …..** whose **N ^{th}** term is

**⌊√n⌋**.

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the integer ` `// part of the geometric mean ` `// of the divisors of n ` `int` `geometricMean(` `int` `n) ` `{ ` ` ` `return` `sqrt` `(n); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 16; ` ` ` ` ` `cout << geometricMean(n); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `class` `GFG ` `{ ` ` ` `// Function to return the integer ` `// part of the geometric mean ` `// of the divisors of n ` `static` `int` `geometricMean(` `int` `n) ` `{ ` ` ` `return` `(` `int` `) Math.sqrt(n); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String []args) ` `{ ` ` ` `int` `n = ` `16` `; ` ` ` `System.out.println(geometricMean(n)); ` `} ` `} ` ` ` `// This code is contributed by Rajput-Ji ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` `from` `math ` `import` `sqrt ` ` ` `# Function to return the integer ` `# part of the geometric mean ` `# of the divisors of n ` `def` `geometricMean(n) : ` ` ` ` ` `return` `int` `(sqrt(n)); ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `n ` `=` `16` `; ` ` ` ` ` `print` `(geometricMean(n)); ` ` ` `# This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to return the integer ` `// part of the geometric mean ` `// of the divisors of n ` `static` `int` `geometricMean(` `int` `n) ` `{ ` ` ` `return` `(` `int` `) Math.Sqrt(n); ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main(String []args) ` `{ ` ` ` `int` `n = 16; ` ` ` `Console.WriteLine(geometricMean(n)); ` `} ` `} ` ` ` `// This code is contributed by PrinciRaj1992 ` |

*chevron_right*

*filter_none*

**Output:**

4

## Recommended Posts:

- Check if the given array contains all the divisors of some integer
- Find sum of divisors of all the divisors of a natural number
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Divisors of n-square that are not divisors of n
- Geometric Progression
- Geometric mean (Two Methods)
- Program for sum of geometric series
- Find N Geometric Means between A and B
- Sum of Arithmetic Geometric Sequence
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Program to print GP (Geometric Progression)
- Number of terms in Geometric Series with given conditions
- Program for N-th term of Geometric Progression series
- Number of GP (Geometric Progression) subsequences of size 3
- Removing a number from array to make it Geometric Progression

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.