Daily Challenge (132 Part Series)
Given the following sequence, what is the number of total values for the odd terms of the sequence, up to the n-th term. The number n will be given as a positive integer.
f(0) = 0 f(1) = 1 f(2) = 1 f(3) = 2 f(4) = 4; f(n) = f(n-1) + f(n-2) + f(n-3) + f(n-4) + f(n-5);
1 is the only value that will be duplicated in the sequence, it should only be counted once.
countPentafib(5) => 1
because the terms up to 5 are: [0, 1, 1, 2, 4, 8], 1 is the only odd and is only counted once.
countPentafib(10) => 3
[1, 1, 31, 61] are each odd and should be counted.
countPentafib(15) => 5
[1, 1, 31, 61, 1793, 3525] are all odd and 1 is only counted once.
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!
Become a better developer by putting these principles into practice. Readability, maintainability, performance, security and clean code are all important, but don't forget about communication, teamwork, and passion.