I'm a CS student and i got this question in my C++ assignment and i don't understand the math behind it.
the question is:
For a natural number m we define its n-th root to be the natural number k that exists That-n k is closer to m than any nth power of any other natural number 'k.
for example: A. What is the tenth root of a hundred? In other words: what is the number x so that: 10 near x to a hundred more than any other number to the power of ten? The answer: 1. B. What is the third root of a hundred? What is the number whose third power is close to one hundred More than any other number in the third? The answer: 5.
Write a program that reads a natural number. The plan must present its second to ninth roots of the number.
I didn't understand how they say they define the nth root of a number and the examples provided didn't help me understand it. hope that someone has an idea so i understand what the program I'm coding is supposed to do.
Obviously, this is not the standard definition of the $n$th root in mathematics, so I will not use the $\sqrt[n]{\cdot}\ $ notation.
Lets say we want to compute the $3$rd root of $100$. We need to find the integer $x$ such that for all other integers $y$, we have that $x^3$ is closer to $100$ than $y^3$. "Closer" here, I believe, means the distance in terms of the absolute value of the difference of the two numbers.
If we make a list:
\begin{align} 1^3 &= 1 & |100-1| &= 99\\ 2^3 &= 8 & |100-8| &= 92\\ 3^3 &= 27 & |100-27| &= 73\\ 4^3 &= 64 & |100-64| &= 36 \\ 5^3 &= 125& |100-125| &= 25\\ 6^3 &= 216& |100-216| &= 116 \end{align}
Since $5^3$ is closer to $100$ than any other, $5$ is the $3$rd root of $100$.