The last digit of 1 + 2 + + n 1+2+\cdots+n and a related squence

Algebra Level 4

Let's define a squence { a n } n N \{a_{n}\}_{n\in \mathbb N} such that a n a_{n} is the last digit of 1 + 2 + 3 + + n 1+2+3+\cdots+n for n N . n\in \mathbb N.

If S n = k = 1 n a k , S_{n}=\displaystyle\sum_{k=1}^{n}{a_{k}}, what is the value of S 2018 ? S_{2018}?


The answer is 7070.

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.

2 solutions

Haosen Chen
Mar 10, 2018

You may find the squence { a n } \{a_{n}\} is periodic.

In fact, ( n + 20 ) ( n + 20 + 1 ) 2 = n 2 + 41 n + 420 2 = n ( n + 1 ) 2 + 20 n + 210 \frac{(n+20)(n+20+1)}{2} = \frac{n^{2}+41n+420}{2} =\frac{n(n+1)}{2} +20n+210 , which implies the last digit of ( n + 20 ) ( n + 21 ) 2 \frac{(n+20)(n+21)}{2} and n ( n + 1 ) 2 \frac{n(n+1)}{2} are equal.

So a n + 20 = a n a_{n+20}=a_{n} , and S 2018 = S 18 + 100 S 20 S_{2018}=S_{18}+100S_{20} .

S 20 = k = 1 20 a k = 1 + 3 + 6 + 0 + 5 + 1 + 8 + 6 + 5 + 5 + 6 + 8 + 1 + 5 + 0 + 6 + 3 + 1 + 0 + 0 = 70 S_{20}=\displaystyle\sum_{k=1}^{20}{a_{k}}=1+3+6+0+5+1+8+6+5+5+6+8+1+5+0+6+3+1+0+0=70 and S 18 = 70 S_{18}=70 .

Thus S 2018 = 7070 S_{2018}=\boxed{7070} .

Piero Sarti
Mar 11, 2018

Let f ( n ) = n ( n + 1 ) 2 f(n) = \dfrac{n(n+1)}{2} ,

Now computing the first few values of f ( n ) f(n) ,

f ( 1 ) = 1 a 0 = 1 f(1) = 1 \implies a_0 = 1

f ( 2 ) = 3 a 1 = 3 f(2) = 3 \implies a_1 = 3

f ( 3 ) = 6 a 2 = 6 f(3) = 6 \implies a_2 = 6

f ( 4 ) = 10 a 3 = 0 f(4) = 10 \implies a_3 = 0

You may notice that a 1 a 0 = 2 , a 2 a 1 = 3 a_1 - a_0 = 2, a_2 - a_1 = 3 and so on.

This means that:

a n + 1 = ( a n + ( n + 1 ) ) ( m o d 10 ) a_{n + 1} = \left(a_n + (n + 1)\right)\pmod {10}

a n + 2 = ( ( a n + 1 ( m o d 10 ) ) + ( n + 2 ) ) ( m o d 10 ) a_{n + 2} = \left(\left( a_{n + 1}\pmod{10} \right)+ (n + 2)\right)\pmod {10}

Now generalizing:

a n + k = ( ( ( ( ( a n ( m o d 10 ) ) + ( n + 1 ) ) ( m o d 10 ) + ( n + 2 ) ) ( m o d 10 ) + ) ( m o d 10 ) + ( n + k ) ) ( m o d 10 ) a_{n + k} = \left(\left(\left(\left(\left(a_n\pmod{10}\right) + (n + 1)\right)\pmod{10} + (n + 2)\right)\pmod{10} + \cdots\right) \pmod{10} + (n + k)\right)\pmod{10} .

Because we start with a 0 a_0 and go up to a 2018 a_{2018} we can now run the following program:

1
2
3
4
5
6
7
8
a = 1
sum = 1

for n in range(1, 2018):
    a = (a + (n + 1)) % 10
    sum  = sum + a

print(sum)

The final output of the variable sum , is 7070 \boxed{7070} .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...