Question

Write code in Python: explain with comments Starting with two one-digit positive integers a and b,...

Write code in Python: explain with comments

Starting with two one-digit positive integers a and b, consider the sequence in which the next number is the digit in the ones place of the sum of the previous two numbers. For example, if a = 1 and b = 1, the sequence is 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7, 0, … Write a function mystery(a, b) that returns the length of the sequence when the last two numbers repeat the values of a and b for the first time. For example, if a = 1 and b = 1, the function should return 62.

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Note: Brother sometimes while uploading on HomeworkLib the indentations change. So, I request you to verify it with screenshot once. This is the link where I have saved the code too

https://onlinegdb.com/S1SmBF-cS

def mystery(a,b):
f1=a;
f2=b;
ct=2;
while(True):
c=(a+b)%10;
a=b;
b=c;
ct+=1;
if(f1==a and f2==b):
return ct;
print(mystery(1,1));

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write code in Python: explain with comments Starting with two one-digit positive integers a and b,...
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
ADVERTISEMENT