login
a(n) = Sum_{k=0..n} sign(A007953(5*k) - A007953(k)).
2

%I #43 Jun 20 2020 13:28:01

%S 0,1,0,1,0,1,0,1,0,0,1,2,3,4,5,6,7,8,8,9,8,9,8,9,8,9,8,8,7,6,7,8,9,10,

%T 11,12,12,13,12,13,12,13,12,13,12,12,11,10,9,8,9,10,11,12,12,13,12,13,

%U 12,13,12,13,12,12,11,10,9,8,7,6,7,8,8,9,8,9,8

%N a(n) = Sum_{k=0..n} sign(A007953(5*k) - A007953(k)).

%C The sign function is defined by:

%C - sign(0) = 0,

%C - sign(n) = +1 for any n > 0,

%C - sign(n) = -1 for any n < 0.

%C The graph of the sequence has some similarities with a Takagi (or blancmange) curve.

%C Visually, the sequence is of fractal nature; for k > 2, the scatterplot of the first 10^k terms is similar to that of the first 10^(k+1) terms.

%C We also have symmetries:

%C - for k = 1..6: let m_k = (10^k)/2-1: for i = 0..m_k, we have a(m_k - i) = a(m_k + i),

%C - this relation is conjectured to hold for any k > 0,

%C - this would be equivalent to saying that, for any k > 0 and i = 0..m_k, sign(A007953(5*(m_k - i)) - A007953(m_k - i)) = - sign(A007953(5*(m_k + i + 1)) - A007953(m_k + i + 1)).

%C For b > 1, let d_b be the digital sum in base b; in particular:

%C - d_2 = A000120,

%C - d_3 = A053735,

%C - d_10 = A007953.

%C For any b > 1 and n >= 0, d_b(b*n) = d_b(n).

%C Also, a(n) = Sum_{k=0..n} sign(d_10(5*k) - d_10(k)).

%C For b > 1, i > 0 and j > 0 such that neither i nor j are divisible by b, let F(b,i,j) be the function defined by n -> Sum_{k=0..n} sign(d_b(i*k) - d_b(j*k)); in particular:

%C - F(10,5,1) = a (this sequence).

%C Also, F(b,i,i) = 0 and F(b,i,j) = -F(b,j,i).

%C Conjecturally, we have three kinds of behaviors:

%C - if i = j, then F(b,i,j) = 0,

%C - otherwise if i and j divide b, then F(b,i,j) has infinitely many zeros (and infinitely many nonzero values), and has similar fractal nature and exhibits similar symmetries as the present sequence,

%C - otherwise |F(b,i,j)| tends to infinity (and has only a finite number of zeros).

%C a(n) = 0 for n = 0, 2, 4, 6, 8, 9, 89, 90, 92, 94, 96, 98, 99, 899, 900, 902, 904, 906, 908, 909, 989, 990, 992, 994, 996, 998, 999, 8999, ...

%H Rémy Sigrist, <a href="/A289411/b289411.txt">Table of n, a(n) for n = 0..10000</a>

%H Rémy Sigrist, <a href="/A289411/a289411.png">Scatterplot of F(10,5,1) (this sequence)</a>

%H Rémy Sigrist, <a href="/A289411/a289411_1.png">Scatterplot of F(10,2,1)</a>

%H Rémy Sigrist, <a href="/A289411/a289411_2.png">Scatterplot of F(10,5,2)</a>

%H Rémy Sigrist, <a href="/A289411/a289411_3.png">Scatterplot of F(10,7,1)</a>

%H Rémy Sigrist, <a href="/A289411/a289411_4.png">Scatterplot of F(18,6,3)</a>

%H Rémy Sigrist, <a href="/A289411/a289411_5.png">Scatterplot of F(42,7,2)</a>

%e The first terms, alongside the digital sum of 5*n and n, and the sign of their difference, are:

%e n a(n) d_10(5*n) d_10(n) sign

%e -- ---- --------- ------- ----

%e 0 0 0 0 0

%e 1 1 5 1 +1

%e 2 0 1 2 -1

%e 3 1 6 3 +1

%e 4 0 2 4 -1

%e 5 1 7 5 +1

%e 6 0 3 6 -1

%e 7 1 8 7 +1

%e 8 0 4 8 -1

%e 9 0 9 9 0

%e 10 1 5 1 +1

%e 11 2 10 2 +1

%e 12 3 6 3 +1

%e 13 4 11 4 +1

%e 14 5 7 5 +1

%e 15 6 12 6 +1

%e 16 7 8 7 +1

%e 17 8 13 8 +1

%e 18 8 9 9 0

%e 19 9 14 10 +1

%e 20 8 1 2 -1

%e 21 9 6 3 +1

%e 22 8 2 4 -1

%e 23 9 7 5 +1

%e 24 8 3 6 -1

%e 25 9 8 7 +1

%t With[{s = Table[Total@ IntegerDigits[5 k] - Total@ IntegerDigits@ k, {k, 0, 76}]}, Table[Total@ Map[Sign, Take[s, n]], {n, Length@ s}]] (* _Michael De Vlieger_, Jul 20 2017 *)

%o (PARI) a(n) = sum(k=0, n, sign(sum digits(5*k) - sum digits(k)))

%o (Python)

%o from sympy import sign

%o from sympy.ntheory.factor_ import digits

%o def a(n): return sum([sign(sum(digits(5*k)[1:]) - sum(digits(k)[1:])) for k in range(n + 1)])

%o print([a(n) for n in range(51)]) # _Indranil Ghosh_, Aug 02 2017

%Y Cf. A000120, A007953, A053735.

%K nonn,base,look

%O 0,12

%A _Rémy Sigrist_, Jul 18 2017