Given an integer **N**, the task is to find the smallest **N-digit** number which is a perfect fourth power.

**Examples:**

Input:N = 2

Output:16

Only valid numbers are 2^{4}= 16

and 3^{4}= 81 but 16 is the minimum.

Input:N = 3

Output:256

4^{4}= 256

**Approach:** It can be observed that for the values of **N = 1, 2, 3, …**, the series will go on like **1, 16, 256, 1296, 10000, 104976, 1048576, …** whose **N ^{th}** term will be

**pow(ceil( (pow(pow(10, (n – 1)), 1 / 4) ) ), 4)**.

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 smallest n-digit ` `// number which is a perfect fourth power ` `int` `cal(` `int` `n) ` `{ ` ` ` `double` `res = ` `pow` `(` `ceil` `((` `pow` `(` `pow` `(10, ` ` ` `(n - 1)), 1 / 4) )), 4); ` ` ` `return` `(` `int` `)res; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 1; ` ` ` `cout << (cal(n)); ` `} ` ` ` `// This code is contributed by Mohit Kumar ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `class` `GFG ` `{ ` ` ` `// Function to return the smallest n-digit ` `// number which is a perfect fourth power ` `static` `int` `cal(` `int` `n) ` `{ ` ` ` `double` `res = Math.pow(Math.ceil(( ` ` ` `Math.pow(Math.pow(` `10` `, ` ` ` `(n - ` `1` `)), ` `1` `/ ` `4` `) )), ` `4` `); ` ` ` `return` `(` `int` `)res; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `n = ` `1` `; ` ` ` `System.out.println(cal(n)); ` `} ` `} ` ` ` `// This code is contributed by CodeMech ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` `from` `math ` `import` `*` ` ` `# Function to return the smallest n-digit ` `# number which is a perfect fourth power ` `def` `cal(n): ` ` ` `res ` `=` `pow` `(ceil( (` `pow` `(` `pow` `(` `10` `, (n ` `-` `1` `)), ` `1` `/` `4` `) ) ), ` `4` `) ` ` ` `return` `int` `(res) ` ` ` `# Driver code ` `n ` `=` `1` `print` `(cal(n)) ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to return the smallest n-digit ` `// number which is a perfect fourth power ` `static` `int` `cal(` `int` `n) ` `{ ` ` ` `double` `res = Math.Pow(Math.Ceiling(( ` ` ` `Math.Pow(Math.Pow(10, ` ` ` `(n - 1)), 1 / 4) )), 4); ` ` ` `return` `(` `int` `)res; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `n = 1; ` ` ` `Console.Write(cal(n)); ` `} ` `} ` ` ` `// This code is contributed ` `// by Akanksha_Rai ` |

*chevron_right*

*filter_none*

**Output:**

1

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.

## Recommended Posts:

- Sum of fourth power of first n even natural numbers
- Find two numbers whose difference of fourth power is equal to N
- Find smallest perfect square number A such that N + A is also a perfect square number
- Count numbers upto N which are both perfect square and perfect cube
- Smallest N digit number whose sum of square of digits is a Perfect Square
- Largest N digit Octal number which is a Perfect square
- Sum of fourth powers of the first n natural numbers
- Sum of fourth powers of first n odd natural numbers
- Find the cordinates of the fourth vertex of a rectangle with given 3 vertices
- Smallest and Largest N-digit perfect cubes
- Smallest and Largest N-digit perfect squares
- Count of N-digit numbers having digit XOR as single digit
- Check if a number is a perfect square having all its digits as a perfect square
- Smallest N digit number which is a multiple of 5
- Check if given number is a power of d where d is a power of 2
- Perfect power (1, 4, 8, 9, 16, 25, 27, ...)
- Count perfect power of K in a range [L, R]
- Calculate sum of all integers from 1 to N, excluding perfect power of 2
- Minimum steps to reach the Nth stair in jumps of perfect power of 2
- Find the Largest N digit perfect square number in Base B

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.