As you probably know, a Fibonacci Number is one which is the sum of the previous two numbers in the series.
A Fibonacci Digit™ is one which is the sum of the two previous digits.
For instance, for the series beginning 1,1
, the series would be 1,1,2,3,5,8,13,4,7,11,2...
The change occurs after the 13
, where, instead of adding 8+13
, you add 1+3
. The series loops at the end, where 4+7=11
, and 1+1=2
, same as the series starts.
For another example, the series beginning 2,2
: 2,2,4,6,10,1,1,2,3,5,8,13,4,7,11,2,3...
. This one starts out uniquely, but once the digits sum to 10
, you end up with 1+0=1, 0+1=1
, and the series continues - and loops - the same way the 1,1
series did.
The Challenge
Given an integer input 0≤n≤99
, calculate the loop in the Fibonacci Digit series beginning with those two digits. (You are certainly allowed to consider integers out of this range, but it's not required.) If given a one-digit input, your code should interpret it to denote the series beginning 0,n
.
All numbers in the loop that are two-digits must be outputted as two digits. So, for instance, the loop for 1,1
would contain 13
, not 1,3
.
The output begins with the first number in the loop. So, based on the above restrictions, the loop for 1,1
begins with 2
, since 1,1
and 11
are counted separately.
Each number of the output may be separated by whatever you want, as long as it's consistent. In all of my examples I use commas, but spaces, line breaks, random letters, etc. are all allowed, as long as you always use the same separation. So 2g3g5g8g13g4g7g11
is a legal output for 1
, but 2j3g5i8s13m4g7sk11
is not. You can use strings, lists, arrays, whatever, provided that you have the correct numbers in the correct order separated by a consistent separator. Bracketing the entire output is also allowed (ex. (5,9,14)
or [5,9,14]
, etc.).
Test Cases:
1 -> 2,3,5,8,13,4,7,11
2 -> 2,3,5,8,13,4,7,11
3 -> 11,2,3,5,8,13,4,7
4 -> 3,5,8,13,4,7,11,2
5 -> 2,3,5,8,13,4,7,11
6 -> 3,5,8,13,4,7,11,2
7 -> 14,5,9
8 -> 13,4,7,11,2,3,5,8
9 -> 11,2,3,5,8,13,4,7
0 -> 0
14 -> 5,9,14
59 -> 5,9,14
This is code-golf, so the lowest number of bytes wins.
14
and59
give the same result. If59
is interpreted as starting5,9
and allowing that as part of the loop then surely14
should be the start of its loop? \$\endgroup\$0,1,1,2,3,5,8,13,4,7,11,2,3
. The first time that the loop repeats is at the second2
. \$\endgroup\$1,4,5,9,14,5
and5,9,14,5,9
. Both of them repeat beginning with the second5
. As I said earlier, only the input is split up; later numbers keep their digits together in the sequence. \$\endgroup\$