OddFib.py 1 #Recall that Fibonacci's sequence is a sequence of numbers 2 #where every number is the sum of the two previous numbers. 3 #Now imagine a modified sequence, called the Oddfib sequence. 4 #The Oddfib sequence is exactly like Fibonacci's sequence 5 #except that if the number is even, we add one to it to make 6 #it odd. 7 # 8 #Here are the first several digits of the Oddfib sequence 9 #for reference; the top row gives the numbers themselves, 10 #and the bottom row gives their indices: 11 # 12 # 13 # 14 # 15 #For example, for the 3rd Oddfib number: 1 + 1 is 2, and 2 16 #is even, so the 3rd Oddfib number is 3. For the 5th Oddfib 17 #number, 3 + 5 is 8, and 8 is even, so the 5th Oddfib number 18 #is 9. 19 # 20 #You may choose whether to implement oddfib recursively or 21 #with a loop. 22 23 24 #Write your code here! 25 9. 15 5 67 109 177 287 465 753 9 10 25 41 7 8. 11 12 13 14 26 27 28 #Below are some lines of code that will test your function. 29 #You can change the value of the variable(s) to test your 30 #function with different inputs. 31 # 32 #If your function works correctly, this will originally 33 #print: 3, 9, 67, each on its own line. 34 print (oddfib(3)) 35 print(oddfib(5)) 36 print (oddfib(9)) 37 38 39 40 Next > < Previous 54 33 12 11
OddFib.py 1 #Recall that Fibonacci's sequence is a sequence of numbers 2 #where every number is the sum of the two previous numbers. 3 #Now imagine a modified sequence, called the Oddfib sequence. 4 #The Oddfib sequence is exactly like Fibonacci's sequence 5 #except that if the number is even, we add one to it to make 6 #it odd. 7 # 8 #Here are the first several digits of the Oddfib sequence 9 #for reference; the top row gives the numbers themselves, 10 #and the bottom row gives their indices: 11 # 12 # 13 # 14 # 15 #For example, for the 3rd Oddfib number: 1 + 1 is 2, and 2 16 #is even, so the 3rd Oddfib number is 3. For the 5th Oddfib 17 #number, 3 + 5 is 8, and 8 is even, so the 5th Oddfib number 18 #is 9. 19 # 20 #You may choose whether to implement oddfib recursively or 21 #with a loop. 22 23 24 #Write your code here! 25 9. 15 5 67 109 177 287 465 753 9 10 25 41 7 8. 11 12 13 14 26 27 28 #Below are some lines of code that will test your function. 29 #You can change the value of the variable(s) to test your 30 #function with different inputs. 31 # 32 #If your function works correctly, this will originally 33 #print: 3, 9, 67, each on its own line. 34 print (oddfib(3)) 35 print(oddfib(5)) 36 print (oddfib(9)) 37 38 39 40 Next > < Previous 54 33 12 11
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Python
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY