login
a(n) = |2*n - 10^length(n)|.
1

%I #25 Dec 11 2022 16:09:36

%S 8,6,4,2,0,2,4,6,8,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52,50,48,

%T 46,44,42,40,38,36,34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2,0,2,

%U 4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40

%N a(n) = |2*n - 10^length(n)|.

%C The plot looks like multiple V shapes. A new V shape occurs for each interval n = 10^k .. 10^(k+1)-1, with the bottom of the V at a(5*10^k) = 0.

%C All terms are even.

%H Rémy Sigrist, <a href="/A343275/b343275.txt">Table of n, a(n) for n = 1..9999</a>

%H Erhan Tezcan, <a href="https://github.com/erhant/burning_castle">Github Repo</a> includes plots and the code.

%F a(n) = abs(2*n - 10^A055642(n)).

%F a(10*n) = 10*a(n).

%e n=10 has length 2, so a(10) = |20-100| = 80.

%t Table[Abs[2n-10^IntegerLength[n]],{n,70}] (* _Harvey P. Dale_, Dec 11 2022 *)

%o (Python)

%o def a(n : int) -> int:

%o return abs((n << 1) - (10 ** len(str(n))))

%o (PARI) a(n) = abs(2*n-10^max(1, #digits(n))) \\ _Rémy Sigrist_, May 30 2021

%Y Cf. A055642.

%K nonn,base

%O 1,1

%A _Erhan Tezcan_, Apr 10 2021