OFFSET
0,3
COMMENTS
!n is a subfactorial number (A000166).
EXAMPLE
Subfactorial(0) = 1 begins with 1, so a(1) = 0 ;
Subfactorial(3) = 2 begins with 2, so a(2) = 3 ;
Subfactorial(14) = 32071101049 begins with 3, so a(3) = 14.
MAPLE
for n from 1 to 100 do:l1:=length(n):i:=0:for m from 1 to 400 while(i=0)do:
s:=0:for j from 0 to m do: s:=s+m!*(((-1)^j)*1/j!) :od:x:=s:l:=length(x):y:=floor(x/(10^(l-l1))):if y=n and l>=l1 then i:=1: printf ( "%d %d \n", n, m): else fi:od:od:
MATHEMATICA
f[n_] := Block[{k = 0, m}, While[m = Max[0, Floor@Log[10, Subfactorial[k]] - Floor@Log[10, n]]; (Subfactorial[k] - Mod[Subfactorial[k], 10^m])/10^m! = n, k++]; k]; Array[f, 67] (* program from David W. Wilson - see A018799 Nov 05 2010 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Oct 14 2011
EXTENSIONS
a(0)=1 prepended by Alois P. Heinz, Feb 02 2017
STATUS
approved