OFFSET
0,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..400
FORMULA
a(n) = Product_{i=1..n} c(i), where c(i) = A089186(i) is the difference between i and the next power of 10 (for example, c(13) = 100 - 13 = 87; c(100) = 1000 - 100 = 900). - Emeric Deutsch, Jul 31 2005
EXAMPLE
a(3) = (10-3)*(10-2)*(10-1) = 7*8*9 = 504.
MAPLE
s:=proc(m) nops(convert(m, base, 10)) end: for q from 1 to 120 do c[q]:=10^s(q)-q od: a:=n->product(c[i], i=1..n): seq(a(n), n=0..20); # Emeric Deutsch, Jul 31 2005
# Alternative:
a:= proc(n) option remember; `if`(n=0, 1,
(10^length(n)-n)*a(n-1))
end:
seq(a(n), n=0..30); # Alois P. Heinz, Sep 22 2015
PROG
(PARI) a(n) = prod(i=1, n, 10^(1+logint(i, 10))-i); \\ Jinyuan Wang, Aug 09 2025
(Python)
from functools import cache
def a(n): return 1 if n == 0 else (10**len(str(n))-n)*a(n-1)
print([a(n) for n in range(21)]) # Michael S. Branicky, Aug 13 2025
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Amarnath Murthy, Jul 29 2005
EXTENSIONS
More terms from Emeric Deutsch, Jul 31 2005
a(0)=1 prepended by Alois P. Heinz, Aug 13 2025
STATUS
approved
