Hello,
this is the task in checkio:
"You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't forget that the first element has the index 0.
Let's look at a few examples:
- array = [1, 2, 3, 4] and N = 2, then the result is 32 == 9;
- array = [1, 2, 3] and N = 3, but N is outside of the array, so the result is -1.
Input: Two arguments. An array as a list of integers and a number as a integer.
Output: The result as an integer.
Example:
indexpower([1, 2, 3, 4], 2) == 9
indexpower([1, 3, 10, 100], 3) == 1000000
indexpower([0, 1], 0) == 1
indexpower([1, 2], 3) == -1"
**I marked bold where I thought that this is a mistake. The index N (0) is "0" in that example. So the number to pick is "0". and the N-th power of "0" is "0". But the output is 1.
What is wrong in my thoughts ??:D
Thanks! **
Created at: 2016/01/28 08:22; Updated at: 2016/01/28 08:37