Divisible by Every Common Divisor of a a and b b

Find the number of pairs of positive integers ( a , b ) (a,b) with 1 a < b 100 1\leq a < b \leq 100 such that

there is at least one positive integer m m with a < m < b a<m<b such that m m is divisible by every common divisor of a a and b . b.


The answer is 4568.

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.

5 solutions

Arjen Vreugdenhil
Dec 28, 2017

It is easier to count for how many of the ( 100 2 ) = 4950 \binom{100}{2} = 4950 pairs ( a , b ) (a,b) the condition is not met.

Let d d be the greatest common divisor, then a = x d a = xd , b = y d b = yd , and there should not exist an m m such that m = n d m = nd . But this means that there is no integer between x x and y y ; therefore y = x + 1 y = x + 1 .

For any given value of d d there are 100 / d \lfloor 100/d \rfloor positive integers less than or equal to 100, and therefore N ( d ) = 100 / d 1 N(d) = \lfloor 100/d \rfloor - 1 of the pairs ( x , y ) (x,y) . Thus we count:

d N ( d ) pairs 1 99 99 2 49 49 3 32 32 4 24 24 5 19 19 6 15 15 7 13 13 8 11 11 9 10 10 10 9 9 11 8 8 12 7 7 13 14 6 12 15 16 5 10 17 20 4 16 21 25 3 15 26 33 2 16 34 50 1 17 total 382 \begin{array}{ccc} d & N(d) & \text{pairs} \\ \hline 1 & 99 & 99 \\ 2 & 49 & 49 \\ 3 & 32 & 32 \\ 4 & 24 & 24 \\ 5 & 19 & 19 \\ 6 & 15 & 15 \\ 7 & 13 & 13 \\ 8 & 11 & 11 \\ 9 & 10 & 10 \\ 10 & 9 & 9 \\ 11 & 8 & 8 \\ 12 & 7 & 7 \\ 13-14 & 6 & 12 \\ 15-16 & 5 & 10 \\ 17-20 & 4 & 16 \\ 21-25 & 3 & 15 \\ 26-33 & 2 & 16 \\ 34-50 & 1 & 17 \\ \hline \text{total} & & 382 \end{array}

Thus the solution is 4950 382 = 4568 4950 - 382 = \boxed{4568} .

That's it!

Muhammad Rasel Parvej - 3 years, 5 months ago

and here i am brute forcing the solution in a work sheet (G.C.D function used; 100 (100*100 size) tables used) -.-

Eliud Alejandro Maldonado Sanchez - 3 years, 5 months ago

Log in to reply

That's the power of mathematical reasoning :)

Arjen Vreugdenhil - 3 years, 5 months ago

So I'm confused. I did exactly as you did to get 382 but I thought those were the valid pairs? I mean like (30,90) should be a valid pair with m=60, right?

Abdel Halloway - 3 years, 5 months ago

Log in to reply

Yes, ( 30 , 90 ) (30,90) is a valid pair.

For d = 30 d = 30 , I ruled out the two invalid pairs ( 30 , 60 ) (30,60) and ( 60 , 90 ) (60,90) .

Arjen Vreugdenhil - 3 years, 5 months ago

...where N(d) is the number of pairs (x,y) that differ by d and don't meet the condition.

Richard Desper - 3 years, 5 months ago

Exactly as how I did it. I suggest you to add "greatest" before "common divisor" to be more precise.

Ron van den Burg - 3 years, 4 months ago
Victor Dumbrava
Jan 8, 2018

I've written a Python 3 program to solve this for us:

1
2
3
4
5
6
7
8
divisors = lambda n: [x for x in range(1, n + 1) if n % x == 0]
s = 0
for i in range(1,101):
    for j in range(1, 101):
        if i < j:
            comdiv = {*divisors(i)} & {*divisors(j)}
            s += any(m for m in range(i + 1, j) if all(m % div == 0  for div in comdiv))
print(s)

This will yield the correct result, 4568 .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def divisors(n): 
    div = [x for x in range(1, n + 1) if n % x == 0]
    return div

s = 0
for i in range(1,101):
    for j in range(1, 101):
        if i < j:
            comdiv = set(divisors(i)).intersection(divisors(j))
            s += any(m for m in range(i + 1, j) if all(m % div == 0  for div in comdiv))
            #print '%d, %d: %s' %(i, j, sorted(list(comdiv)))
print s

1
4568

Michael Fitzgerald - 3 years, 5 months ago

Python 2.7

Michael Fitzgerald - 3 years, 5 months ago
Meneghin Mauro
Jan 11, 2018

This is equivalent to pairs 1 < = a < b < = 100 1<=a<b<=100 such that b a g c d ( a , b ) b-a \neq gcd(a,b)

My python solution

1
2
3
4
5
6
7
from fractions import gcd
count = 0
for a in range(1,100):
  for b in range(a+1,101):
    if (b-a)!=gcd(a,b):
      count += 1
print(count)

here is a matlab code to solve the problem

X = [] ;
for a = 1:99
    for b = (a+1):100
        for m = (a+1):(b-1)
            if mod(m,gcd(a,b)) == 0
                X = [X; a b] ;
                break
            end
        end
    end
end
k = size(X,1)

Of course it returns the same k = 4568 k = 4568 that everyone else mention :)

The matrix X X saves all the valid pairs.

Instead of your inner loop on m, just test if (b-a)/gcd(a,b)>=2. If so, there must be another multiple of their gcd between them.

Jerry Barrington - 3 years, 4 months ago

In the programming package M a t h e m a t i c a Mathematica the solution is obtained by means of a simple program. i.e.

k = 1; Do[

            Do[

                  If[Mod[m, GCD[a, b]] == 0, k++ && Goto[end]], 

            {m, a + 1, b - 1}]; 

             Label[end], 

     {a, 1, 98}, {b, 3, 100}]; Print["k = ", k - 1]

After counting wrong twice I decided to decrease the 100 in the problem to n=1,2,... and look for a sequence in OEIS.

It's easy to find the first terms 0,0,1,2,5,7,12,16,22,28 and a search returns https://oeis.org/A161664 which gives some alternate methods.

I just looked at the 100th term.

Jeremy Galvagni - 2 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...