6 kyu

Pentabonacci

785 of 2,189raulbc777

Description:

We have the following sequence:

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);

Your task is to give the number of total values for the odd terms of the sequence up to the n-th term (included). (The number n (of n-th term) will be given as a positive integer)

The values 1 (one) is the only that is duplicated in the sequence and should be counted only once.

E.g.

count_odd_pentaFib(5) -----> 1 # because the terms up to 5 are: 0, 1, 1, 2, 4, 8 (only 1 is odd and counted once)

Other examples:

 count_odd_pentaFib(10) ------> 3 #because the odds terms are: [1, 1, 31, 61] (three different values)

count_odd_pentaFib(15) ------> 5 # beacause the odd terms are: [1, 1, 31, 61, 1793, 3525] (five different values)

Good luck !!

(Your code should be fast. Many moderate high values will be waiting to test it.)

Fundamentals
Mathematics
Algorithms
Performance
Dynamic Programming

Stats:

CreatedAug 10, 2015
PublishedAug 19, 2015
Warriors Trained5409
Total Skips661
Total Code Submissions11411
Total Times Completed2189
Python Completions785
Haskell Completions95
Ruby Completions74
JavaScript Completions358
CoffeeScript Completions12
Java Completions402
C# Completions193
Clojure Completions50
Elixir Completions116
Scala Completions43
Groovy Completions16
COBOL Completions7
C++ Completions129
Go Completions36
Rust Completions70
D Completions7
Total Stars109
% of votes with a positive feedback rating91% of 354
Total "Very Satisfied" Votes302
Total "Somewhat Satisfied" Votes37
Total "Not Satisfied" Votes15
Ad
Contributors
  • raulbc777 Avatar
  • bkaes Avatar
  • g964 Avatar
  • Unnamed Avatar
  • suic Avatar
  • kazk Avatar
  • Voile Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • Tim-Fedor Avatar
  • saudiGuy Avatar
Ad