Adding digits and divisibilities

1 × 2 × 3 × × 2018 \large 1\times2\times3\times\cdots\times2018 My computer solves for the above product and finds its digit sum (sum of all its digits). It then repeats this process of calculating the digit sum until only one digit remains.

What digit is that?

6 7 8 9

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.

16 solutions

Marta Reece
Jan 26, 2018

Relevant wiki: Divisibility Rules (2,3,5,7,11,13,17,19,...)

The number, 2018 ! 2018! , is definitely divisible by 9 9 . The sum of its digits is as well, etc. So the last remaining digit too has to be divisible by 9 9 , which can only happen if it is 9 \boxed9

Moderator note:

This relies on the fact that a whole number's sum of digits is divisible by 9 if and only if the number is divisible by 9.

Here's a short proof for the 3-digit case, which can easily be extended to any number of digits.

We can write a number with a a hundreds, b b tens and c c ones as

100 a + 10 b + 1 c . 100a + 10b + 1c.

Move out an a a and b b term together with the c c

99 a + 9 b + 1 a + 1 b + 1 c 99a + 9b + 1a + 1b + 1c

which we can write as using three terms:

99 a + 9 b + ( a + b + c ) . 99a + 9b + (a+b+c).

9 divides 99 and 9, so the only restriction to the number being divisible by 9 is a + b + c ; a+b+c ; that is, the sum of the digits. That term being divisible by 9 means the whole number is divisible by 9 (and vice versa).

Why is it definitely divisible by 9? Is it a rule of factorials that the original number's, in this case 2018, factorial is divisible by the same numbers?

Mohammed Al-Awami - 3 years, 4 months ago

Log in to reply

Yes, because you are multiplying by 9, it has to be divisible by 9. A separate fact is that the sum of the digits of any number divisible by 9 is divisible by 9. By reapplication of the second fact, you can get the solution.

Alex Li - 3 years, 4 months ago

Log in to reply

Okay I see. Thank you for the explanation :)

Mohammed Al-Awami - 3 years, 4 months ago

It is definitely divisible by 9 because 2018 is divisible by 9 (2018/9 = 224), so a factorial will also be (you're just multiplying 2018 by 2017!, so dividing it by 9 will equals 224 * 2017!, which is an integer). Then she just applied the rule to know when a number is divisible by 9, which is that the sum of its digits must also be divisible by 9, so at the end the result can only be 9.

Carlos Paramio Danta - 3 years, 4 months ago

Log in to reply

Any factorial from 9! above is divisible by 9, since it is product containing 9 as one of the factors.

Marta Reece - 3 years, 4 months ago

Log in to reply

@Marta Reece True, even more elegant :) Thanks

Carlos Paramio Danta - 3 years, 4 months ago

@Marta Reece It goes even lower. Since the prime factorization of 6 is 2 × \times 3 and 3 < < 6, any factorial from starting from 6! is divisible by 9.

Akeel Howell - 3 years, 4 months ago

Log in to reply

@Akeel Howell True that. I just did the simplest thing available.

Marta Reece - 3 years, 4 months ago

2018 is not divisible by 9... 2018/9 is 224.2222... But the fact remains that its factorial is, as explained by Marta Reece

Benoît Lu - 3 years, 4 months ago

i dont get why the last digit has to be 9 like 99 is divisible by 9 and its sum is 18, but it doesnt end with a 9

Hazem Salem - 3 years, 4 months ago

Log in to reply

But you are not to one digit. To get there, you need to add up 1+8=9. And you do get a 9.

Marta Reece - 3 years, 4 months ago

Log in to reply

Oh you need to get to one digit. I should read questions better. I thought they meant the last digit of the product.

Hazem Salem - 3 years, 4 months ago

The number that was divisible by 9 in the original post wasn't the "last digit" of the number, but the "last remaining digit" after repeating the process of adding up the digits.

Iskander Elderson - 3 years, 4 months ago

How is a hundreds if it's 99?

Adam Smith - 3 years, 4 months ago

This is so cool because it means that for every factorial of a number bigger than 8, the last digit sum is always 9!

Razvan Tepeneu - 3 years, 2 months ago

Log in to reply

It's actually true for factorials of all integers greater than 5.

Akeel Howell - 3 years, 2 months ago
1
2
3
4
5
6
7
x = 1
factorial = 2018
for i in range(1,factorial+1):
    x = x*i
while len(str(x)) > 1:
    x = sum([int(digit) for digit in str(x)])
    print x

1
2
3
23598
27
9

In python3 you can use a generator expression instead of a list comprehension, so you can drop the [] in the digitsum formula. Also, there is a built-in factorial in the math library.

Bryn Dickinson Staff - 3 years, 4 months ago

cheating, just joking. hehe.

Francis Dave Cabanting - 3 years, 4 months ago

import math

n = math.factorial(factorial)

(but you can also use the solution above, with "Divisiblity Rules" so you dont need a computer...)

Michael Biermann - 3 years, 4 months ago

I realize thx. It was a one time loop so I figured I'd calculate myself.

Michael Fitzgerald - 3 years, 4 months ago

How do you put python code in your solution?

I read the solution-writing/formatting guides but no mention of it there.

Thanks in advance, from a newbie.

Markus Pfaff - 3 years, 4 months ago

Log in to reply

Here you go https://brilliant.org/math-formatting-guide/

Michael Fitzgerald - 3 years, 4 months ago

my favourite solution!

Ash Norsidi - 3 years, 3 months ago
Mevan Alles
Feb 5, 2018

Multiples of 9 has digit sums divisible by 9 as well. 2018! contains multiple of 9 as 9 itself is contained in the factorial. i.e. 1x2x....9x...2018

But so is 6, 7, and 8, so why is the answer 9?

Sytse Durkstra - 3 years, 4 months ago

Log in to reply

Well... Its a special property that holds for a number divisible by 9. It can contain any other factors. But as long the those factors contain 9 (or 3 x 3), the digit sum is divisible by 9. You can repeat this until there is only 1 digit and the property still holds. It wont hold true for other factors. i.e. the ones you have mentioned 6,7,8. I'll briefly try to explain.

Let a number be represented as ABCDE (you can extend this to any number of digits as you like). Now this can be written as; E + 10D + 100C + 1000B + 10000A

or

E + D + 9D + C + 99C + B + 999B + A + 9999A = E + D + C + B + A + 9D + 99C + 999B + 9999A

So if you say ABCDE is divisible by 9, then it means (E + D + C + B + A + 9D + 99C + 999B + 9999A ) is divisible by 9 too.

For E + D + C + B + A + 9D + 99C + 999B + 9999A to be divisible by 9 it's clear that sum of E + D + C + B + A must be divisible by 9 as well. i.e. the digit sum. (rest of the terms as automatically divided by 9 regardless of the digit value)

Mevan Alles - 3 years, 4 months ago

Log in to reply

I wanted to ask the same question, somehow you explained it in a more understandable way than "Challange Master Note" Thank You ^^

Mocc Flocc - 3 years, 4 months ago

And, any ! that is 6 or higher will have digit sums of 9 since it contains x3 and x6 which is 3x2. So they all are multiples of 9. 6! has a digit sum of 9 as does 7! and 8!, Etc.

Ashlie Warnick - 3 years, 4 months ago
Priti Gupta
Feb 5, 2018

2018! is divisible by 9 as 2018! = 1x2x3x...9x10x11....2018 and the divisibility rule of 9 says that the sum of the digits till the digit remains a single one must be 9. Therefore the answer is 9

Extra: Every factorial of a number above 5 has the same property

Trevor Reed
Feb 6, 2018
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import math

# Define our recursive function, digSum(), that takes an int
def digSum(num):
    # End condition: if there's only one digit, print it
    if num < 10:
        print num
    # Else, keep summing the digits
    else:
        digSum(sum(int(i) for i in str(num)))

# Call our function with 2018! as the int
digSum(math.factorial(2018))

In this solution, we begin with 2018 ! 2018! as our input integer and repeatedly sum the digits using Python's powerful string capabilities.

The heavy lifting is done here:

1
2
else:
        digSum(sum(int(i) for i in str(num)))

Here, we recursively call our function, digSum(num) , with the result of its most recent input. Starting with 2018 ! 2018! , we sum() all of the integers, i , in the number, num . To accomplish this, we convert our number into a string with str(num) , allowing us to iterate over the number one digit at a time with a for statement, making summing the digits easy! So essentially, this line is saying:

For all of the characters in the number string, turn them into integers and sum them all together.

This is done multiple times until we check and find that there is a single digit remaining, bringing us to our answer, 9 \boxed{9} .

Vivian James
Feb 9, 2018

Any multiple of 9 has a digital root of 9. 2018! is a multiple of 9, so its digital root must be 9.

Tucker S
Feb 9, 2018

In the given set, every integer from 1 to 2018 is given. (This can also be expressed as 2018! )Given that every number is being multiplied together and one of those numbers is 9, we can conclude that the final number will be 9. How? Divisibility rules tell us that the digits of any multiple of 9 will add up to be a multiple of 9. From that logic, we can conclude that when this process is repeated, the end result will be 9.

Good explanation! Divisibility rules is very helpful here.

Bonus: What if the computer computes the number in a different base q q , would the solving technique be any different?

Pi Han Goh - 3 years, 4 months ago
Jam M
Feb 5, 2018

If x N x \in \mathbb{N} , then the digital root d ( x ) d(x) of x x is the single-digit number obtained by iteratively summing up the digits of x x and its subsequent iterations. Moreover, d ( x ) x m o d 9 d(x) \equiv x \hspace{-.3cm} \mod{9} . To see this, write the decimal expansion of x x and note that the n t h n^{th} term in the expansion is congruent to the n t h n^{th} digit of x x modulo 9. Since 2018 ! 2018! is divisible by 9, so is the single-digit number d ( x ) d(x) . Therefore, d ( x ) = 9 d(x) = 9

The number 2018! is congruent to 0 (mod 9) since 9 appears in there at least once. Let n = 2018!. The canonical representation of n in base ten is n = n 0 1 0 0 + n 1 1 0 1 . . . + n r 1 0 r n = n_0 10^0 + n_1 10^1... + n_r 10^r . Notice that since 10 1 ( m o d 9 ) , n n 1 + n 2 + + n r ( m o d 9 ) 10 \equiv 1 \pmod 9 , n \equiv n_1 + n_2 + \dots + n_r \pmod 9 . This means that the sum of the digits of a number is congruent to the number itself mod 9. So when we get the number m from doing this process repeatedly we should note that m n ( m o d 9 ) m \equiv n \pmod 9 and since m is one digit and n is 0 (mod 9) [or 9 (mod 9)] we can be sure of our answer m =9

Idan Zur
Feb 5, 2018

A simple python code with recursion does the trick:

1
2
3
4
5
6
7
from math import factorial
def digit_sum(n):
    if n<10:
        return n
    return digit_sum(sum(int(i) for i in str(n)))

print digit_sum(factorial(2018))

And of course that the output is:

1
9

Srinand Yashaswi
Feb 5, 2018

The 'digit sum' of any number that's divisible by 9 is 9.

2018! is divisible by 9. So repeatedly obtaining the digit sum gives 9

Similarly, The 'digit sum' of any number that's divisible by 3 is 3.

So, does there exists another single digit integer N (besides 3 and 9) such that the 'digit sum' of any number that's divisible by N is N?

Pi Han Goh - 3 years, 4 months ago
Abhik Biswas
Feb 10, 2018

In 2018! ,it is divisible by 9 then the sum so.So, out of 4 option 9 is divisible by 9.So it is correct

Dalal Talhaoui
Feb 10, 2018

Here is how I did it: 2018! Is divisible by 9

은지 최
Feb 8, 2018

I just used my calculator untill E(error) appeared. I typed in 1×2× ... ×21 then 5.10909422E+19 appeared and the last number was 9!

Good attempt. It's good to realize that the digital sum of 6 ! , 7 ! , 8 ! , 6!, 7!, 8!, \ldots are seemingly all 9. The next step is to prove that they are all indeed 9.

Pi Han Goh - 3 years, 4 months ago
Wenyuan Bao
Feb 7, 2018

Watch VSauce's fixed-point video .

Tcg Klsa
Feb 7, 2018

It seems that the result is always 9 from 6 ! 6!

Yes, do you know why the result is always 9 for n ! n! , where n = 6 , 7 , 8 , 9 , n =6,7,8,9,\ldots ?

Pi Han Goh - 3 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...