Question

In javascript pls Challenge 2 – Fibonacci Create a function called FibonacciMaker that takes in a...

In javascript pls

Challenge 2 – Fibonacci Create a function called FibonacciMaker that takes in a single number and returns an array of that size filled with Fibonacci numbers (starting with 0).

Use case: var fibArray = FibonacciMaker()

Challenge 4 – Random Integer in Range Write a function to return a random integer between a minimum value and maximum value.

var ival = IntRandomRange(, );

Homework Answers

Answer #1

Hi, as per limited time i have solved only first one, so post other question again.

if you have any problem in solution do comment I'll be happy to help you.

code:

// your code goes here
var fibArray = function (n) 
{
  if (n===1) 
  {
    return [0, 1];
  } 
  else 
  {
    var s = fibArray(n - 1);
    s.push(s[s.length - 1] + s[s.length - 2]);
    return s;
  }
};

//console.log(fibArray(8));
//console.log(fibArray(9));
console.log("Enter your number");
response = readline()
//i subtract one because need numbers from zero onwards
console.log(fibArray(response-1));
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
Write a flatten function in JavaScript that uses recursion to create an array containing all nested...
Write a flatten function in JavaScript that uses recursion to create an array containing all nested arrays in a single array. The function should pass the test: it("longer list, no mutation, completely flat", function () { var data = [[[1],2,[3]],4,[5,6]]; var orig_data = data; expect(ms.flatten(data)).toEqual([1,2,3,4,5,6]); expect(data).toEqual(orig_data); });
Write a function makeDoubles in c++, that takes an integer parameter called size and: allocates a...
Write a function makeDoubles in c++, that takes an integer parameter called size and: allocates a new array of that many double's initializes all elements to be 0 returns this array
python pls Create function math_life() this function takes one or more argument. If this function called...
python pls Create function math_life() this function takes one or more argument. If this function called with no argument, raise typeError. The math_life() function returns to a function defined inside. this will take a one argument. For the second argument, it will calculate second function passed to math_life(). You should assume that the math_life() passed x functions, when it called the x times it will calculate the xth function passed to math_life() arguments when it called x+1 time it again...
Write a function that takes in 3 arguments: a sorted array, size of the array, and...
Write a function that takes in 3 arguments: a sorted array, size of the array, and an integer number. It should return the position where the integer value is found. In case the number does not exist in that array it should return the index where it should have been if it were present in this sorted array. Use pointer notation of arrays for this question.
• First, create a function called addNumber, which has a formal parameter for an array of...
• First, create a function called addNumber, which has a formal parameter for an array of integers and increase the value of each array element by a random integer number between 1 to 10. o Add any other formal parameters that are needed. • Second, create another function called printReverse that prints this array in reverse order. • Then, you need to write a C++ program to test the use of these two functions.
Need HTML and JS code. Write a Javascript function named RandomString(randomStringLength) that returns a string filled...
Need HTML and JS code. Write a Javascript function named RandomString(randomStringLength) that returns a string filled with random characters where the length of the random string is defined by the input parameter. HINT: Use a for-loop, Math.random, and the fact that the alphabet has 26 characters (remembering that we can have both lower-case and upper-case characters in a string). This is what I have: <html> <!-- inputbox.html Jerry Davis --> <!-- Web page that sets the correct letter value. -->...
1.Write a function which takes a string that contains two words separated by any amount of...
1.Write a function which takes a string that contains two words separated by any amount of whitespace, and returns a string in which the words are swapped around and the whitespace is preserved. Hint: use regular expressions where \s detects the whitespaces in a string. Example: given "Hello     World", return "World         Hello" 2.Pandas exercises: Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. Write a python program using Pandas to...
C++ Write a function that takes in 3 arguments: a sorted array, size of the array,...
C++ Write a function that takes in 3 arguments: a sorted array, size of the array, and an integer number. It should return the position where the integer value is found. In case the number does not exist in that array it should return the index where it should have been if it were present in this sorted array. Use pointer notation of arrays for this question. c++ code
Create a function called lists_Sum(lists) that takes in a list of lists, each element in each...
Create a function called lists_Sum(lists) that takes in a list of lists, each element in each sublist will be a number. Your function will return the product of all the numbers in the inner lists added together. solve for python EX.  lists_sum ([[2,2],[3,5],[5,8]]) returns 59
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT