%I #44 Dec 07 2023 11:40:18
%S 2,5,6,8,14,19,34,35,36,38,40,41,43,47,50,51,53,62,67,74,84,85,86,88,
%T 90,91,93,97,109,110,111,113,115,116,118,122,129,132,145,146,148,150,
%U 151,153,162,167,174,177,180,181,183,189,194,200,201,203,212,217
%N Numbers whose factorial has '2' as its final nonzero digit.
%C From _Robert Israel_, Dec 16 2016: (Start)
%C If k is in the sequence, then:
%C if k == 0 (mod 5), k+1 is in the sequence;
%C if k == 1 (mod 5), k+1 is in A045548;
%C if k == 2 (mod 5), k+1 is in A045549;
%C if k == 3 (mod 5), k+1 is in A045550. (End)
%H Robert Israel, <a href="/A045547/b045547.txt">Table of n, a(n) for n = 1..10000</a>
%H <a href="/index/Fi#final">Index entries for sequences related to final digits of numbers</a>
%p count:= 0:
%p r:= 1:
%p for n from 2 while count < 100 do
%p r:= r*n;
%p if r mod 10 = 0 then r:= r/10^padic:-ordp(r, 5) fi;
%p if r mod 10 = 2 then count:= count+1; A[count]:= n fi;
%p od: seq(A[i], i=1..100); # _Robert Israel_, Dec 16 2016
%t f[ n_Integer, m_Integer ] := (c = 0; p = 1; While[ d = Floor[ n/5^p ]; d > 0, c = c + d; p++ ]; Mod[ n!/10^c, m ] ); Select[ Range[ 250 ], f[ #, 10 ] == 2 & ]
%t Join[{2},Select[Range[5,220],Most[Split[IntegerDigits[#!]]][[-1,1]] == 2&]] (* _Harvey P. Dale_, May 04 2016 *)
%t f[n_] := Mod[6 Times @@ (Rest[ FoldList[{1 + #1[[1]], #2! 2^(#1[[1]] #2)} &, {0, 0}, Reverse[ IntegerDigits[n, 5]]]]), 10][[2]] (* after _Jacob A. Siehler_ & _Greg Dresden_ in A008904 *); f[0] = f[1] = 1; Select[ Range[150], f[#] == 2 &] (* _Robert G. Wilson v_, Dec 28 2016 *)
%o (PARI) lnz(n)=if(n<2, return(1)); my(m=Mod(1,5)); for(k=2,n, m*=k/10^valuation(k,5)); lift(chinese(Mod(0,2),m))
%o is(n)=lnz(n)==2 \\ _Charles R Greathouse IV_, Dec 16 2016
%o (PARI) list(lim)=my(v=List(),m=Mod(1,5)); for(k=2,lim, m*=k/10^valuation(k,5); if(m==2, listput(v, k))); Vec(v) \\ _Charles R Greathouse IV_, Dec 16 2016
%o (Python)
%o from functools import reduce
%o from itertools import count, islice
%o from sympy.ntheory.factor_ import digits
%o def A045547_gen(startvalue=1): # generator of terms
%o return filter(lambda n:2==reduce(lambda x,y:x*y%10,((1,1,2,6,4)[a]*((6,2,4,8)[i*a&3] if i*a else 1) for i, a in enumerate(digits(n,5)[-1:0:-1])))*6%10, count(max(startvalue,1)))
%o A045547_list = list(islice(A045547_gen(),30)) # _Chai Wah Wu_, Dec 07 2023
%Y Cf. A008904, A045548, A045549, A045550.
%K nonn,base
%O 1,1
%A _Jeff Burch_