Define subfactorial ( ) as
Find the six-digit number such that .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
First lets start by defining a couple things on the board
k! means k factorial, where 0!=1, 1!=1, 2!=2, 3!=6, etc.
the parenthesis (n, k) means n choose k, also written as n! / ( k! * (n-k)!)
once we have those defined we can calculate the subfactorial for each number 0-9 as follows:
!0 = 1
!1 = 0
!2 = 1
!3 = 2
!4 = 9
!5 = 44
!6 = 265
!7 = 1854
!8 = 14833
!9 = 133496
Now the brute forcing comes in, we can loop through every 6 digit number 000000-999999 and convert the digits into a sum using the conversion chart above. The first number to come back where the converted total equals the original number is our answer, 148349.