A045549 Numbers whose factorial has '6' as its final nonzero digit.
3, 12, 17, 24, 29, 32, 45, 46, 48, 59, 60, 61, 63, 65, 66, 68, 72, 79, 82, 95, 96, 98, 104, 107, 120, 121, 123, 127, 130, 131, 133, 139, 144, 159, 160, 161, 163, 165, 166, 168, 172, 175, 176, 178, 187, 192, 199, 209, 210, 211, 213, 215, 216, 218
Offset: 1
Links
Programs
-
Maple
count:= 0: r:= 1: for n from 2 while count < 100 do r:= r*n; if r mod 10 = 0 then r:= r/10^padic:-ordp(r,5) fi; if r mod 10 = 6 then count:= count+1; A[count]:= n fi; od: seq(A[i],i=1..100); # Robert Israel, Dec 16 2016
-
Mathematica
Join[{3}, Select[Range[5,250], Most[Split[IntegerDigits[#!]]][[-1, 1]] == 6 &]] (* Vincenzo Librandi, Dec 16 2016 *) 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[#] == 6 &] (* Robert G. Wilson v, Dec 28 2016 *) Select[Range[250],With[{f=#!},Drop[IntegerDigits[f],-IntegerExponent[f]][[-1]]]==6&] (* Harvey P. Dale, Sep 27 2024 *)
-
Python
from itertools import count, islice from functools import reduce from sympy.ntheory.factor_ import digits def A045549_gen(startvalue=2): # generator of terms >= startvalue return filter(lambda n:6==reduce(lambda x,y:x*y%10,(((6,2,4,8,6,2,4,8,2,4,8,6,6,2,4,8,4,8,6,2)[(a<<2)|(i*a&3)] if i*a else (1,1,2,6,4)[a]) for i, a in enumerate(digits(n,5)[-1:0:-1])),6), count(max(startvalue,2))) A045549_list = list(islice(A045549_gen(),30)) # Chai Wah Wu, Dec 07 2023
Comments