If you look at the Fibonacci Numbers, you will notice a pattern in their parity:
0, 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144. Every third number is even, and all the others are odd. This makes sense because an even plus an odd is odd, but an odd plus an odd is even and the sum for a term will always include at least one even number unless the last two terms were odd, which happens every three terms.
In this challenge you will have to look at a generalization of this problem.
- You will be given as input two positive integers describing the Fibonacci integer sequence you will have to look at.
- For example,
0, 1describes the original Fibonacci numbers, and
2, 1would be the Lucas numbers. The sequence is calculated with the recurrence relation:
- You will also take a positive integer
- Your code has to output the parity of the nth term of the described Fibonacci integer sequence (0 indexed).
- The output format can be any two sane, consistent outputs (e.g.
0for even and
(Fibonacci numbers) [0, 1], 4 -> odd (Lucas numbers) [2, 1], 9 -> even [14, 17], 24 -> even [3, 9], 15 -> odd [2, 4], 10 -> even