Divisibility

Let n n be an integer randomly chosen in the interval [ 1 , 120 ] [1, 120] , and consider the sum S n = k = 1 n k . S_n = \displaystyle \sum_{k=1}^n k.

S n S_n is least likely to be divisible by __________ . \text{\_\_\_\_\_\_\_\_\_\_}.

2 3 4 5

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.

6 solutions

Jimin Khim Staff
Aug 26, 2017
n n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ... Pattern Probability
i = 1 n \sum_{i=1}^n 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 ...
Divisible by 2 ? 2? (x x o o) (x x o o) (x x o o) (x x o o) ... Repeated every 4 numbers 2 4 = 1 2 \frac24=\frac12
Divisible by 3 ? 3? (x o o) (x o o) (x o o) (x o o) (x o o) (x ... Repeated every 3 numbers 2 3 \frac23
Divisible by 4 ? 4? (x x x x x x o o) (x x x x x x o o) ... Repeated every 8 numbers 2 8 = 1 4 \frac28=\frac14
Divisible by 5 ? 5? (x x x o o) (x x x o o) (x x x o o) (x ... Repeated every 5 numbers 2 5 \frac25

How does one show that this pattern continues?

Agnishom Chattopadhyay - 3 years, 9 months ago

Why isn't 5 preferred over 4?

Fahad Bin Halim - 3 years, 9 months ago

The question is just-- sum of n natural nose,, now for consecutive numbers,, to check if divisible by a no. We check blocks of that no. Like for 2 we take 2 no in a block, similarly 3 for 3, 4 for 4.

So for the sum,, probabilty in a block for sum to be multiple, For 2 probabilty is 1/2=50% For 3=> 1/3 =33.33/ For 4 = 1/4 =25% For 5= 2/5 =40% ((1+2+3+4 divisible by5, 1+2+3+4+5 divisible by 5))

Thus, lowest probability is for 4.

Ambuj Priyadarshi - 3 years, 8 months ago
Ivan Koswara
Aug 27, 2017

Relevant wiki: Sum of n, n², or n³

Note that

S = i = 1 n i = n ( n + 1 ) 2 S = \displaystyle \sum_{i=1}^n i = \frac{n(n+1)}{2}

Note that n , n + 1 n, n+1 are relatively prime to each other. Let d = p k d = p^k be a prime power that divides S S (which is true for all four options in the problem). Suppose 2 d = a b 2d = ab , such that a a divides n n and b b divides n + 1 n+1 . We divide into two cases:

  • If p p is odd, then the factor of 2 is irrelevant. One of n n and n + 1 n+1 is necessarily even, so n ( n + 1 ) n(n+1) is divisible by 2. It remains to see whether it is divisible by d d or not. Since d d is a prime power, we cannot have a , b > 2 a, b > 2 together, since that would imply p p divides both a , b a, b and thus n , n + 1 n, n+1 , contradicting the fact that n , n + 1 n, n+1 are both relatively prime. Thus only one of a , b a, b is greater than 2. WLOG a > 2 a > 2 . Then b b is not divisible by p p , so a a is divisible by d d .
  • If p = 2 p = 2 , then we follow the similar approach as above, except now that the factor of 2 is absorbed into d d . We need a b = 2 k + 1 ab = 2^{k+1} . It cannot happen that both a , b > 1 a, b > 1 , as that would mean 2 divide both a , b a, b and thus both n , n + 1 n, n+1 . So one of a , b a, b is 1, and the other is thus necessarily 2 k + 1 2^{k+1} .

The conclusion is that if p p is odd, then one of n , n + 1 n, n+1 must be divisible by d d , while if p p is even, then one of n , n + 1 n, n+1 must be divisible by 2 d 2d . It's easy to see that if these conditions are satisfied, then indeed S S is divisible by d d .

Since n , n + 1 n, n+1 is relatively prime, if we pick n n uniformly at random, n n is divisible by m m with probability 1 m \frac{1}{m} and n + 1 n+1 is divisible by m m with probability 1 m \frac{1}{m} , and the two cannot happen simultaneously. Thus S S is divisible by m m with probability 2 m \frac{2}{m} . For odd d d , pick m = d m = d , while for even d d , pick m = 2 d m = 2d , as above. Since we pick n n from the range [ 1 , 120 ] [1, 120] , we indeed have " n n is divisible by d d " being a uniformly random event for d = 2 , 3 , 4 , 5 d = 2, 3, 4, 5 (since 2 , 3 , 4 , 5 2, 3, 4, 5 divide 120). This gives the following:

  • A: d = 2 d = 2 , so m = 4 m = 4 , so S S is divisible by 2 with probability 2 4 \frac{2}{4} .
  • B: d = 3 d = 3 , so m = 3 m = 3 , so S S is divisible by 3 with probability 2 3 \frac{2}{3} .
  • C: d = 4 d = 4 , so m = 8 m = 8 , so S S is divisible by 4 with probability 2 8 \frac{2}{8} .
  • D: d = 5 d = 5 , so m = 5 m = 5 , so S S is divisible by 5 with probability 2 5 \frac{2}{5} .

Thus 4 has the smallest probability.

Does this pattern tend to some limiting behaviour when the interval is made arbitrarily large?

Agnishom Chattopadhyay - 3 years, 9 months ago

Log in to reply

Yes; the probabilities tend to the same values as above.

Ivan Koswara - 3 years, 9 months ago
Vu Vincent
Sep 4, 2017

Relevant wiki: Sum of n, n², or n³

Theorem:

S j n , j n 1 0 ( m o d m ) S_{ jn, jn-1} \equiv 0 \pmod { m} for odd n n

S 2 j n , 2 j n 1 0 ( m o d n ) S_{ 2jn, 2jn-1} \equiv 0 \pmod { n } for even n n

for a range of n n in which n , j Z + n, j \in \mathbb{Z^+}

Proof:

  • Odd n n

Let n = 2 k 1 n=2k-1 , k Z + k \in \mathbb{Z^+} :

S n = S 2 k 1 = ( 2 k 1 ) 2 k 2 = k ( 2 k 1 ) 0 ( m o d 2 k 1 ) \Rightarrow S_n = S_{2k-1} = \frac{(2k-1)2k}{2} = k(2k-1) \equiv 0 \pmod {2k-1}

This congruence (i.e when S n 0 ( m o d 2 k 1 ) S_n \equiv 0 \pmod {2k-1} ) occurs every consecutive 2 k 1 2k-1 . So, for every j ( 2 k 1 ) j \cdot (2k-1) where j Z + j \in \mathbb{Z^+} :

S j ( 2 k 1 ) 0 ( m o d 2 k 1 ) S_j(2k-1) \equiv 0 \pmod {2k-1}

or in terms of odd n n :

S j n 0 ( m o d n ) S_jn \equiv 0 \pmod {n}

  • Even n n

Let n = 2 k n=2k , k Z + k \in \mathbb{Z^+} :

S n = S 2 k = 2 k ( 2 k + 1 ) 2 = k ( 2 k + 1 ) k ( m o d 2 k ) \Rightarrow S_n = S_{2k} = \frac{2k(2k+1)}{2} = k(2k+1) \equiv k \pmod {2k}

Here, S 2 k 0 ( m o d 2 k ) S_{2k} \equiv 0 \pmod {2k} doesn't occur every consecutive 2 k 2k . Rather, it occurs every 2 consecutive 2 k 2k i.e every 4 k 4k ( This is in order to add another k k for obtaining S m 0 ( m o d 2 k ) S_m \equiv 0 \pmod {2k} . Observing that S 4 k = 2 k ( 4 k + 1 ) 0 ( m o d 2 k ) S_{4k} = 2k(4k+1) \equiv 0 \pmod {2k} ). So, for every j 4 k j \cdot 4k where j Z + j \in \mathbb{Z^+} :

S 4 k j 0 ( m o d 2 k ) S_{4kj} \equiv 0 \pmod {2k}

or in terms of n n :

S 2 j n 0 ( m o d n ) S_{2jn} \equiv 0 \pmod {n}

Now for both odd and even cases, there could be additional cases when any of the n i n-i where i { 1 , 2 , 3 , . . . , n 1 } i \in \{1,2,3,...,n-1\} can actually yields 0 ( m o d n ) 0 \pmod {n} . We will need to check for what values of i i will this happen.

We have S n i S_{n-i} is the sum that we will need to comment on (an integer n [ 1 , 120 ] n \in [1,120] )

S n i = ( n i ) ( n i + 1 ) 2 S_{n-i} = \frac{(n-i)(n-i+1)}{2}

If n n is even, then we have the case for even n n :

( 2 k i ) ( 2 k i + 1 ) 2 m o d 2 k = ( i 2 ) ( 1 i ) \frac{(2k-i)(2k-i+1)}{2} \mod {2k} = -(\frac{i}{2})(1-i)

We wanted to see when it is divisible by m = 2 k m=2k so we set:

( i 2 ) ( 1 i ) = 0 i = 0 , 1 -(\frac{i}{2})(1-i) = 0 \Rightarrow i= 0,1

Doing this to the case when n n is odd gives the same result, hence, the conclusion is:

S j n , j n 1 0 ( m o d n ) S_{ jn, jn-1} \equiv 0 \pmod { n} for odd n n

S 2 j n , 2 j n 1 0 ( m o d n ) S_{ 2jn, 2jn-1} \equiv 0 \pmod { n } for even n n


We can use this to find probabilities of S n 0 ( m o d n ) S_n \equiv 0 \pmod n , by finding how much of S n S_n is divisible by n n in the range n [ 1 , 120 ] n \in [1,120] :

All numbers n n such that S n S_n is divisible by 2 are: - P ( 2 ) = S 4 j = 120 + S 4 j 1 = 120 120 = 30 60 = 1 2 P(2) = \frac{S_{4j = 120} + S{4j-1=120}}{120} = \frac{30}{60} = \frac{1}{2}

All numbers n n such that S n S_n is divisible by 3 are: - P ( 3 ) = S 3 j = 120 + S 3 j 1 = 120 120 = 80 120 = 2 3 P(3) = \frac{S_{3j = 120} + S{3j-1=120}}{120} = \frac{80}{120} = \frac{2}{3}

All numbers n n such that S n S_n is divisible by 4 are: - P ( 4 ) = S 8 j = 120 + S 8 j 1 = 120 120 = 1 4 P(4) = \frac{S_{8j = 120} + S{8j-1=120}}{120} = \frac{1}{4}

All numbers n n such that S n S_n is divisible by 5 are: - P ( 5 ) = S 5 j = 120 + S 5 j 1 = 120 120 = 24 60 = 2 5 P(5) = \frac{S_{5j = 120} + S{5j-1=120}}{120} = \frac{24}{60} = \frac{2}{5}

It can be seen that P ( 4 ) P(4) is the lowest probability. Therefore, 4 \boxed{4} is least divisible by S n S_n for n [ 1 , 120 ] n \in [1,120]

Incorrect; S n S_n is least likely divisible by, among others, 64, 121, 125, 127, 128, and many more other positive integers, all with probability 0. And in fact, S n S_n is more likely to be divisible by 120 (probability 3/120) than it is divisible by 32 (probability 2/120).

Your fault is because you only consider numbers divisible by m m . For example, when m = 3 m = 3 , you only consider n = 3 , 6 , 9 , 12 , n = 3, 6, 9, 12, \ldots and not n = 2 , 5 , 8 , 11 , n = 2, 5, 8, 11, \ldots (where S n S_n is also divisible by m m ).

Ivan Koswara - 3 years, 8 months ago

Log in to reply

Thanks for pointing that out. I will fix it in my solution

Vu Vincent - 3 years, 8 months ago
Derp McDerpson
Sep 9, 2017

NOTE: This isn't an explanation, just a program.

Program written in Crystal to illustrate results:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def triangle(n)
  n * (n + 1) / 2
end

# Outputs the amount of triangle numbers between 1 and 120
# that are divisible by 2, 3, 4 and 5 respectively.
puts (1..120).select { |a| (triangle(a) % 2).zero? }.size # => 60
puts (1..120).select { |a| (triangle(a) % 3).zero? }.size # => 80
puts (1..120).select { |a| (triangle(a) % 4).zero? }.size # => 30
puts (1..120).select { |a| (triangle(a) % 5).zero? }.size # => 48

I am not familiar with Crystal. Is it a new programming language?

Agnishom Chattopadhyay - 3 years, 9 months ago

Log in to reply

Yep, it's a programming language with Ruby-like syntax and is compiled. Here's a link.

Derp McDerpson - 3 years, 9 months ago
Kyle T
Sep 8, 2017
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php 
$arr = array('2'=>0,'3'=>0,'4'=>0,'5'=>0);
for($i=1;$i<=120;$i++){
    $sum = 0;
    for($j=1;$j<=$i;$j++){
        $sum += $j;
    }
    if($sum%2==0){
        $arr[2]++;
    }
    if($sum%3==0){
        $arr[3]++;
    }
    if($sum%4==0){
        $arr[4]++;
    }
    if($sum%5==0){
        $arr[5]++;
    }
}
asort($arr);
$arr = array_keys($arr);
echo 'answer: '.$arr[0];

I added your code to the solution

Agnishom Chattopadhyay - 3 years, 9 months ago
Lorenz Kies
Sep 8, 2017

Is using python to bruteforce a legitimate way to solve this problem? If so:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
A = []
B = [0,0,0,0]

for i in range(120): #creates an array A containing all triangle numbers from 1 to 120
    A = A + [((i+1)**2)/2+(i+1)/2]


for i in range(120): #checks each number to see if it is divisible by 2,3,4 or 5 and true increments the according value of B
    for j in range(4):
        if A[i] % (j+2) == 0:
            B[j] += 1

print ("B =",B)

1
B is [60, 80, 30, 48]

where B[n] is the amount of numbers diviseble by n+2:

1
B [div by 2, div by 3,div by 4,div by 5]

And yes! The idea was most likeley to solve the problem and show a mathematical proof, but writing a bit of code also solves the problem, be it in another way.

What if the interval was really large?

Agnishom Chattopadhyay - 3 years, 9 months ago

You can do augmented assignment for arrays as well - A += ... is valid Python.

Derp McDerpson - 3 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...