We have the number ```12385```. We want to know the value of the closest cube but higher than 12385. The answer will be ```13824```.

Now, another case. We have the number ```1245678```. We want to know the 5th power, closest and higher than that number. The value will be ```1419857```.

We need a function ```find_next_power``` ( ```findNextPower``` in JavaScript, CoffeeScript and Haskell), that receives two arguments, a value ```val```, and the exponent of the power,``` pow_```, and outputs the value that we want to find.

Let'see some cases:
```python
find_next_power(12385, 3) == 13824

find_next_power(1245678, 5) == 1419857
```
The value, ```val``` will be always a positive integer.

The power, ```pow_```, always higher than ```1```.

Happy coding!!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def find_next_power(val, pow_):
	

Solutions:
def find_next_power(val, pow_):
	return int(val ** (1.0 / pow_) + 1) ** pow_


import math

def find_next_power(val, pow_):
	next_power_value = math.floor(1 + val ** (1 / pow_))
	return next_power_value ** pow_


def find_next_power(val, power):
	return int(val ** (1.0 / power) + 1) ** power


def find_next_power(val, pow_):
	import math
	a = val ** (1.0 / pow_)
	b = math.ceil(a)
	return b ** pow_


find_next_power = lambda n, p: int(n ** (1.0 / p) + 1) ** p


find_next_power = lambda v, p: (int(v ** (1.0 / p)) + 1) ** p


def find_next_power(val, pow_):
	(num, next_power_value) = (1, 1)
	while val > next_power_value:
		next_power_value = num ** pow_
		num += 1
	return next_power_value


from math import ceil

def find_next_power(val, pow_):
	return ceil((val + 1) ** (1 / pow_)) ** pow_