5
1
Background
We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0
and the second one being 1
. The first few elements are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
What we are going to implement today is a similar sequence, starting at 0
and 1
as well, and each term is the sum of the previous two, but the sum's digits are shifted by one place to the right. What does "shifted" mean? – A digit shifted to the right is basically that digit + 1, unless it equals 9
, which maps to 0
instead. Just as a reference, here is the full list of mappings:
0 -> 1; 1 -> 2; 2 -> 3; 3 -> 4; 4 -> 5; 5 -> 6; 6 -> 7; 7 -> 8; 8 -> 9; 9 -> 0
With all that being said, these are the first terms of our Fibonacci-shifted sequence:
0, 1, 2, 4, 7, 22, 30, 63, 4, 78, 93, 282, 486, 879, 2476, 4466, 7053, 22620, 30784, 64515
Given an integer N (non-negative if 0-indexed and positive if 1-indexed), finds the Nth term of the Fibonacci-shifted sequence.
Rules
The output may contain leading zero(es), in case
9
is the first (few) digit(s).Input and output can be handled using any default mean.
Take note that Loopholes are forbidden.
This is code-golf, hence your program will be scored in bytes, with less bytes being better.
1A useless sequence that's not on OEIS..? – Stewie Griffin – 2017-09-07T17:28:28.990
@StewieGriffin Exactly. – Mr. Xcoder – 2017-09-07T17:28:43.150
3On reflection, this should be a duplicate of Fibonacci... it's literally just
digit + 1 mod 10
for each digit after the sum is performed. I have a hammer so I'm not voting, yet. – Conor O'Brien – 2017-09-07T17:49:21.620I'd agree with you (though I also have a hammer) – James – 2017-09-07T17:50:46.707
@ConorO'Brien I'd agree too...also have hammer. – Erik the Outgolfer – 2017-09-07T17:52:01.210
@ConorO'Brien "Hammered" it myself. – Mr. Xcoder – 2017-09-07T17:52:39.100
2Rotating the sum's digits left has a period of 59. – Jonathan Allan – 2017-09-07T17:54:16.373