Computes incrementing Fibonacci numbers starting from 3 until the length of the resulting Fibonacci result is the input value n. Returns the term of the Fibonacci sequence where this occurs. >>> fibonacci_digits_index(1000) 4782 >>> fibonacci_digits_index(100) 476 >
(n: int)
| 56 | |
| 57 | |
| 58 | def fibonacci_digits_index(n: int) -> int: |
| 59 | """ |
| 60 | Computes incrementing Fibonacci numbers starting from 3 until the length |
| 61 | of the resulting Fibonacci result is the input value n. Returns the term |
| 62 | of the Fibonacci sequence where this occurs. |
| 63 | |
| 64 | >>> fibonacci_digits_index(1000) |
| 65 | 4782 |
| 66 | >>> fibonacci_digits_index(100) |
| 67 | 476 |
| 68 | >>> fibonacci_digits_index(50) |
| 69 | 237 |
| 70 | >>> fibonacci_digits_index(3) |
| 71 | 12 |
| 72 | """ |
| 73 | digits = 0 |
| 74 | index = 2 |
| 75 | |
| 76 | while digits < n: |
| 77 | index += 1 |
| 78 | digits = len(str(fibonacci(index))) |
| 79 | |
| 80 | return index |
| 81 | |
| 82 | |
| 83 | def solution(n: int = 1000) -> int: |