The solution to the task does not match its condition
The task description says:
Write a function pow(x,n) that returns x in power n. Or, in other words, multiplies x by itself n times and returns the result. . . . P.S. In this task the function should support only natural values of n: integers up from 1.
The current check for a natural number in the task solution does not take into account the fact that the value passed in can be a fractional value greater than $\large1$. That is, if we pass in, for example, $\large1.1$ as $\large{n}$, the function will execute without any problems, even though $\large{1.1}$ is not a natural number.
This PR proposes an improved check that considers this nuance.
Unless the point of the exercise is to exclude fractional values right? For someone like me, I stuck to whole numbers when I did the exercise. I think it's worth clarifying the requirements of this specific task.
Unless the point of the exercise is to exclude fractional values right? For someone like me, I stuck to whole numbers when I did the exercise. I think it's worth clarifying the requirements of this specific task.
The description of the task must be consistent with the proposed solution. The author's solution does not take into account one nuance, which I described at the beginning of this PR. With the current code, the function can accept nonnatural numbers, even though the task says that it should only accept natural numbers.
There are two solutions to this problem:
- Accept my PR, which excludes the possibility of the function working with nonnatural numbers.
- Paraphrasing the task description, creating a different condition.
Agreed, I'm leaving that to the creator to decide on.