# 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 , hence your program will be scored in bytes, with less bytes being better.

• A useless sequence that's not on OEIS..? Sep 7, 2017 at 17:28
• @StewieGriffin Exactly. Sep 7, 2017 at 17:28
• On 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. Sep 7, 2017 at 17:49
• I'd agree with you (though I also have a hammer) Sep 7, 2017 at 17:50
• Rotating the sum's digits left has a period of 59. Sep 7, 2017 at 17:54

# Python 2, 78 72 bytes

f=lambda n:n>1and int(''.join(-~int(i)%10for i inf(n-1)+f(n-2)))or n


Try it online!

Saved 6 bytes thanks to Halvard Hummel.

• 72 bytes Sep 7, 2017 at 17:39
• Hello and welcome to PPCG! Great first answer! Also, mind if I ask whether you have anything to do with this user? Sep 7, 2017 at 17:43
• @Mr.Xcoder I don't know them, but my name was inspired by theirs. Is that a problem? EDIT: Never mind, might as well change my name.
– user70408
Oct 29, 2017 at 20:08
• @VoteToReopen No, that is not a problem. I was just asking out of cheer curiosity :) Oct 29, 2017 at 20:09

# Jelly, 9 bytes

ð+D‘%⁵Ḍø¡


Try it online!

-2 thanks to Dennis.

Explanation:

ð+D‘%⁵Ḍø¡ Full program. Takes input through STDIN.
+        Add the left (f(n - 1)) and right (f(n - 2)) arguments
D       Get list of decimal digits
‘      Increment each
%⁵    Modulo ⁵ (10)
Ḍ   Convert from decimal to integer
¡ Repeat previous chain z times (where z is taken from STDIN as there are no arguments)

• This is a repost of my answer on the old deleted question. Sep 7, 2017 at 17:12
• If you take input from STDIN, you can eliminate both 0. Sep 7, 2017 at 17:33
• @Dennis I was expecting Jelly-related action of yours after seeing your comment :p EDIT: There was a comment on the question that now got deleted. Sep 7, 2017 at 17:34

# JavaScript (ES6), 63 62 bytes

This is what I'd come up with before the challenge was deleted, don't have time to golf it further now.

Returns the nth number in the sequence, 0-indexed.

f=(n,x=0,y=1)=>n?f(--n,y,+[...x+y+""].map(z=>++z%10).join):x

• 1 byte saved thanks to Conor.

Try it online

## Alternative, 55 bytes

A quick port of VoteToReopen's excellent Python solution.

f=n=>n>1?+[...f(--n)+f(--n)+""].map(x=>++x%10).join:n


Try it online

• -1 byte: change ~~ to + Sep 7, 2017 at 17:47
• Oh, yeah. Thanks, @ConorO'Brien; the ~~ snuck back in there when I rewrote this on my phone. Sep 7, 2017 at 18:02

# J, 40 bytes

[(-&2(10|>:)&.(10&#.inv)@+&$:<:)@.(1&<)  Try it online! Highlighted following is the standard Fibonacci husk: [(-&2 +&$:<:)@.(1&<)


Then, we compose the following function with the result of adding the previous two terms:

      (10|>:)&.(10&#.inv)@


This, in turn, is the function 10|>: atop 10&#.inv, which gets the digits of a number. That is to say, the digits are obtained, then the function 10|>: is applied, then the digits are combined to make a number again. 10|>: is a fork that is equivalent to (y + 1) % 10 in a conventional language for input y.