Question

The Lucas Numbers are a sequence very similar to the Fibonacci sequence discussed in class, the only difference being that the Lucas Numbers start with 10-2 L,-1 as opposed to Fibonaccis Fo = 0 and F1 = 1, concretely, they are defined by Lo = 2, L,-1 and Ln-Ln-l + Ln-2 for n > 1 Write a Python function called first D_digit Lucas that takes an integer argument D less than 30 and returns the first D-digit Lucas number. For example Result Test print(first_D_ digit_Lucas(2)) 11 print(first_ D_digit_Lucas (3)) 123 Answer: (penalty regime: 0 %)

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

def first_D_digit_Lucas(n) :
if (n<30):
#base cases
if (n == 0) :
return 2
if (n == 1) :
return 1

# recurrence relation
return first_D_digit_Lucas(n - 1) + first_D_digit_Lucas(n - 2)

D = int(input("Enter number "))
#to print upto D lucas numbers
for i in range(0,D):
print(first_D_digit_Lucas(i))

#to print D th lucas number
print(first_D_digit_Lucas(i))

Add a comment
Know the answer?
Add Answer to:
The Lucas Numbers are a sequence very similar to the Fibonacci sequence discussed in class, the...
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