### Digit-spines

Hello Math-Fun,
The expression « digit-spine » is absent from the OEIS, which is good for future searches about the hereunder topic (should S, T and U enter the OEIS, of course).

Here is S, the lexicographically earliest sequence of distinct nonnegative integers with the property explained below.
S = 1, 10, 2, 0, 3, 26, 9, 119, 532, 4, 6, 896, 118, 34, 15, …

Call p the closest prime to a(n) and d the absolute difference |a(n)-p|. We have:

S = 1, 10, 2, 0, 3, 26, 9, 119, 532, 4, 6, 896, 118, 34, 15, ...
p = 2  11  2  2  3  23  7  113  523  3  5  887  113  31  13
d = 1   1  0  2  0   3  2    6    9  1  1    9    5   3   2

We see that the successive digits forming d are the same as the successive digits forming S.
We then propose to say that S and d share the same digit-spine.

Here are now T, sq and d, based on the same idea: d is the distance between a(n) and the closest square sq. We have:

T = 10, 1, 2, 6, 42, 20, 7, 11, 4, 56, 3, 5, 21, 30, 43, ...
sq =  9  1  1  4  36  16  9   9  4  49  4  6  25  25  49
d =  1  0  1  2   6   4  2   2  0   7  1  1   4   5   6

T and d share the same digit-spine.

And now, U, same idea, f is the closest Fibonacci number:

U = 12, 10, 4, 1, 17, 6, 7, 41, 27, 48, 25, 9, 11, 62, ...
f = 13   8  3  1  13  5  8  34  21  55  21  8  13  55
d =  1   2  1  0   4  1  1   7   6   7   4  1   2   7

Again, U and d share the same digit-spine.
Best,
É.
_________________________________
Update
Maximilian Hasler was quick to answer — and submit:

Eric,
I think the sequence for squares and Fib's should start with 0 (then go on as you wrote).
I propose these sequences as

I put a link to your blog post, but I refrained from using "spine" which already has several other meanings in OEIS, cf. https://oeis.org/search?q=spine&fmt=short&n=99 (although, yes, there is no "digit-spine" here... but also, is it really a "spine" ? If I understand correctly, the spine would be, e.g., the primes , etc. However, they do not necessarily appear in the sequence (while a "spine" is usually an (important) *part* of the body).

Best wishes,
Maximilian

(PARI) - nicer in OEIS
md(n) = if ( n , digits(n) ,  )
spine ( N = 20, f, S=[], d=[]) = { vector(N, n, my( m, j=1 );
for ( k = 0, oo, setsearch(S, k) && next; while( f(j) < k, j++) ;
m = md ( min ( m = f(j) - k, iferr ( k - f(j-1), E, m) ) ) ;
if ( m == concat( d, md (k) )[1..#m] ,
d = concat( d, md (k) )[#m+1 .. -1]; m=k ; break )); S = setunion(S, [m]); m)}

spine( 20, prime )
= [1, 10, 2, 0, 3, 26, 9, 119, 532, 4, 6, 896, 118, 34, 15, 93, 121, 531, 898, 205, ...]
spine( 20, x->x^2 )
= [0, 10, 1, 2, 6, 42, 20, 7, 11, 4, 56, 3, 5, 21, 30, 43, 12, 31, 14, 8, ...]
spine( 20, fibonacci )
= [0, 12, 10, 4, 1, 17, 6, 7, 41, 27, 48, 25, 9, 11, 62, 30, 42, 15, 26, 43, ...]

https://oeis.org/search?q=spine&fmt=short&n=99

____________________
Merci Maximilian!

### Commentaires

1. For the Fibonacci's, I think it should start with 0, then go on as you suggest.

1. and for squares, too.