20
2
The Challenge
Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would return 26: 121393
as 12 is found within the number (121393) and it is at index 26 of the Fibonacci numbers.
Examples
Given the input:
45
Your program should output:
33: 3524578
Input:
72
Output:
54: 86267571272
Input:
0
Output:
0: 0
Input:
144
Output:
12: 144
Scoring
This is code-golf, so the shortest answer in each language wins.
Can we choose to have 1-indexing instead? – Mr. Xcoder – 2017-07-27T20:45:37.380
@Mr.Xcoder Sure, I updated the challenge. :) – SpookyGengar – 2017-07-27T20:46:55.813
1
Not a duplicate, but pretty close to this challenge.
– Lynn – 2017-07-27T20:49:04.543The 12th fibonacci number is 144, so the last test case should be 12: 144. – fireflame241 – 2017-07-27T20:51:45.027
1
Thread over on math regarding whether Fibonacci sequence is normal or not (this question presumes it is).
– AdmBorkBork – 2017-07-27T20:52:35.683@fireflame241 Good catch! I have fixed the example. :) – SpookyGengar – 2017-07-27T20:53:15.287
1Do we have to use a colon as a separator? Can we output an array/list? – Shaggy – 2017-07-27T22:14:10.753
@AdmBorkBork I think this question even goes a bit further in its presumtion than that thread. That thread would imply that every natural number would appear at some point in the constant, but this would allow overlapping between two numbers:
32
would be in8,1[3,2]1
already instead of in832040
. – JAD – 2017-07-28T07:17:04.1032Related question on math.SE about whether this has a solution for any x – JAD – 2017-07-28T07:58:27.010
@JarkoDubbeldam Good distinction. Thanks for the clarification. – AdmBorkBork – 2017-07-28T12:27:57.713
@Shaggy the colon is not mandatory, it's just a suggestion. – SpookyGengar – 2017-07-28T16:58:45.167