Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my first computerclass, so we are not working in any language. Write a m

ID: 3615225 • Letter: T

Question

This is my first computerclass, so we are not working in any language.

Write a module (you may assume global variables) to calculateand display a Fibonacci series between26 and 270. Include an appropriate module header AND allnecessary statements in the module (including the return statement)to solve the problem. Do not “read in” the data,use assignment statements to set the range. It is NOTnecessary to write the complete algorithm, just themodule.  

A Fibonacci series startswith a pair of numbers (usually 0 and 1) and adds those two numberstogether to get a third number. Drop off the first number andrepeat the adding of the two numbers to get a third number. For example, here is an example Fibonacci series starting with0:

0 1 1 2 3 5 8 13 . . .

The logic goes asfollows:

0 plus 1 equals1

Drop off 0 and repeat with1 plus 1 equals 2

Drop off 1 and repeat with1 plus 2 equals 3

Drop off 1 and repeat with2 plus 3 equals 5

Drop off 2 and repeat with3 plus 5 equals 8

Drop off 3 with 5 plus 8equals 13

And so on . . .

Explanation / Answer

I'm not sure if I understand what you mean by "module". But here'smy crack at it... function fibonacci(){// c1 and c2 will store our current two numbers. Let's start with 0 and 1c1 = 0;c2 = 1;//out will be our output array, it stores the numbers we want to outputout = array();// main loop: repeat while our last number is less than 270while(c2 < 270){// num will be our new numbernum = c1 + c2;// the first number is now set to the old new numberc1 = c2;// the second number is our new if our new number is greater than or equal to 26, save itif(num >= 26){// put the new number at the end of the arrayout[] = num;}}// return our array of fib numbers from 26-270return out;}
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote