OFFSET
0,3
COMMENTS
a(n) is a measure for how well powers of 2 may be approximated by powers of 10. It is e.g. relevant to unit conventions for the magnitude of data (e.g. 1 megabyte is approximately 1 mebibyte). The closely related sequence of distances of the closest integer power of 2 to the n-th power of 10 gives a measure for the precision of floating point expressions in computing applications.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..3322
Wikipedia, Floating-point arithmetic
Wikipedia, Mebibyte
EXAMPLE
For n=2, a(2) = |4-1| = 3.
For n=10, a(10) = min(|2^10-10^3|,|2^10-10^4|) = |1024-1000| = 24.
MAPLE
a:= n-> (m-> (p-> min(m-10^p, 10^(p+1)-m))(ilog10(m)))(2^n):
seq(a(n), n=0..37); # Alois P. Heinz, May 07 2020
MATHEMATICA
A[n_] := Min[Abs[(2^n) - 10^Length[IntegerDigits[2^n]]],
Abs[(2^n) - 10^(Length[IntegerDigits[2^n]] - 1)]]
PROG
(PARI) a(n) = my(i=logint(2^n, 10)); min(abs(10^i-2^n), abs(10*10^i-2^n)); \\ Jinyuan Wang, May 06 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Timon S. Gutleb, May 06 2020
EXTENSIONS
More terms from Jinyuan Wang, May 06 2020
STATUS
approved