(In reply to
Solution by Kurious)
And how does it evaluate when k is not an integer?
(-1)k,
where k=1/n : n is an odd positive integer > 1, is equal to -1
1-k%2*2,
where k=1/n : n is an odd positive integer > 1, is not equal to -1
Also note: where n is an even positive integer, (-1)k becomes an imaginary number.
Other considerations are where k = m/n, such that m/n is a reduced fraction. Many applications have trouble providing anything other than an error message or like.
How can we then evaluate (-1)k using only the operators + (addition), - (subtraction), * (multiplication) and % (modulo)?
Edited on January 28, 2008, 1:10 pm
|
Posted by Dej Mar
on 2008-01-27 22:17:06 |