id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

fibonacciReplacement


The Fibonacci numbers are a sequence of integers starting with 0, 1, 1, 2, 3, 5, ... The next number in the sequence can be found by adding the two previous numbers. However, in this problem we will use a modified version of the Fibonnacci numbers where every nth number (n>=2) is replaced with the value in the parameter replaceNum before calculating the next fibonacci number. The number of fibonacci numbers desired will be indicated with the value in the count parameter. You may assume that count will be a resonably small non-negative integer.


fibonacciReplacement(5, 1, 8) → [0, 1, 1, 2, 1, 3, 4, 7]
fibonacciReplacement(3, 6, 12) → [0, 1, 6, 7, 13, 6, 19, 25, 6, 31, 37, 6]
fibonacciReplacement(5, 0, 14) → [0, 1, 1, 2, 0, 2, 2, 4, 6, 0, 6, 6, 12, 18]

...Save, Compile, Run (ctrl-enter)

public int[] fibonacciReplacement(int n, int replaceNum, int count) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 240 Post-solution available

Copyright Nick Parlante 2017 - privacy