We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Fundamentals
- Even Odd Query
- Discussions
Even Odd Query
Even Odd Query
Sort by
recency
|
146 Discussions
|
Please Login in order to post a comment
The problem is better if some example is given with recursion
Thanks for sharing valuable post Sabexch
This code defines a recursive function find(x, y) to determine whether the value of pow(A[x], find(x+1, y)) is odd or even. World 777
This is bullshit. Problem statement is vague and does not walk through any example. I wish I could give this negative star.
Python oneliner:
Some solutions published below omit the first condition (
x>y
) but it works only because there are no test cases withx>y
andarr[x-1]
even (you can make your own test case to see that it would fail in such event.Explanation: x>y is odd, odd^anything is odd, anything^0 is odd, everything else is even.