Question

6- Ask the user for a number n which is then used to find the Fibonacci...

6- Ask the user for a number n which is then used to find the Fibonacci sequence up to n. Write a python function named Fibonacci that calculates the Fibonacci sequence. startNumber = int(raw_input("Enter the start number here ")) endNumber = int(raw_input("Enter the end number here"))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question, here is the code which accepts the startnumber and end number from user and prints all the fibonacci numbers between the start and end numbers

Here is the code with sample output !

thanks and let me know for any changes or help !!

====================================================================================

startNumber = int(input("Enter the start number here: "))
endNumber = int(input("Enter the end number here: "))

n1 = 0
n2 = 1
next_num=n1
# until the fibonacci number is less than the end number
while next_num<=endNumber:
    # print only if the fibonacci number is greater than the startnumber
    if next_num>=startNumber:
        print(next_num,end=' ')
    # update to the next set of numbers
    next_num=n1+n2
    n1=n2
    n2=next_num

==================================================================================

Add a comment
Know the answer?
Add Answer to:
6- Ask the user for a number n which is then used to find the Fibonacci...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT