You are probably familiar with the Fibonacci sequence where the first two terms are 0, 1
(or sometimes 1, 1
) and every term after that is the sum of the previous two. It starts like this:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Sometimes, the sequence contains numbers that have a particular pattern that I find interesting: the difference between any pair of adjacent digits is the same as any other pair. For instance, in the sequence starting with 0, 1
, the 18th term is 987
. 9-8=1
and 8-7=1
. I am mildly satisfied.
Challenge
Given two initial values F(0)
and F(1)
, output every number in the sequence generated by F(n) = F(n-1) + F(n-2)
that meets the following criteria:
- The difference between any pair of adjacent digits is the same as any other pair
- It is as least three digits long (1 and 2 digit numbers are not interesting for this pattern)
Input
- Two non-negative integers less than 10**10 (10 billion)
Output
- All integers that are less than 10**10 and meet the criteria in the Challenge section
- It is acceptable to output digits greater than 10**10 but it is not a requirement
- Given that repeated digits meet the pattern (e.g.
777
), it is possible that there are infinite numbers that meet the criteria but your program is not required to output forever - If no such integers exist, output whatever you want so long as it's not a number (nothing, null, empty array, error message, sad face, etc.)
- If a number matching the pattern appears more than once in the sequence, you can output it once or as many times as it occurs
- If any input meets the criteria, it should be included in the output
Rules
- Input and Output can be in any standard format
- Standard loopholes are forbidden
- This is code-golf so the shortest code in bytes wins
Examples / Test Cases
Input , Output
[1,10] , []
[0,1] , [987]
[2,1] , [123]
[2,3] , [987]
[61,86] , [147]
[75,90] , [420]
[34,74] , [1234]
[59,81] , [2468]
[84,85] , [7531]
[19,46] , [111]
[60,81] , [222]
[41,42] , [333]
[13,81] , [444]
[31,50] , [555]
[15,42] , [666]
[94,99] , [777]
[72,66] , [888]
[3189,826] , [888888888]
[15,3] , [159,258]
[22,51] , [321,1357]
[74,85] , [159,4444]
[27,31] , [147,11111]
[123,0] , [123,123,123,246,369]
[111,0] , [111,111,111,222,333,555,888]
[111,222] , [111,222,333,555,888]
[33345,692] , [987654321]
[3894621507,5981921703] , [9876543210]
[765432099,111111111] , [111111111,876543210,987654321]
[1976,123] , [123, 2222, 4321, 6543, 45678]
[1976, 123] -> [123, 2222, 4321, 6543, 45678]
,[3189, 826] -> [888888888]
,[33345, 692] -> [987654321]
\$\endgroup\$