Find the number of pairs of positive integers ( a , b ) with 1 ≤ a < b ≤ 1 0 0 such that
there is at least one positive integer m with a < m < b such that m is divisible by every common divisor of a and b .
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.
That's it!
and here i am brute forcing the solution in a work sheet (G.C.D function used; 100 (100*100 size) tables used) -.-
Log in to reply
That's the power of mathematical reasoning :)
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?
Log in to reply
Yes, ( 3 0 , 9 0 ) is a valid pair.
For d = 3 0 , I ruled out the two invalid pairs ( 3 0 , 6 0 ) and ( 6 0 , 9 0 ) .
...where N(d) is the number of pairs (x,y) that differ by d and don't meet the condition.
Exactly as how I did it. I suggest you to add "greatest" before "common divisor" to be more precise.
I've written a Python 3 program to solve this for us:
1 2 3 4 5 6 7 8 |
|
This will yield the correct result, 4568 .
1 2 3 4 5 6 7 8 9 10 11 12 |
|
1 |
|
Python 2.7
This is equivalent to pairs 1 < = a < b < = 1 0 0 such that b − a = g c d ( a , b )
My python solution
1 2 3 4 5 6 7 |
|
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 = 4 5 6 8 that everyone else mention :)
The matrix 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.
In the programming package M a t h e m a t i c a 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.
Problem Loading...
Note Loading...
Set Loading...
It is easier to count for how many of the ( 2 1 0 0 ) = 4 9 5 0 pairs ( a , b ) the condition is not met.
Let d be the greatest common divisor, then a = x d , b = y d , and there should not exist an m such that m = n d . But this means that there is no integer between x and y ; therefore y = x + 1 .
For any given value of d there are ⌊ 1 0 0 / d ⌋ positive integers less than or equal to 100, and therefore N ( d ) = ⌊ 1 0 0 / d ⌋ − 1 of the pairs ( x , y ) . Thus we count:
d 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 − 1 4 1 5 − 1 6 1 7 − 2 0 2 1 − 2 5 2 6 − 3 3 3 4 − 5 0 total N ( d ) 9 9 4 9 3 2 2 4 1 9 1 5 1 3 1 1 1 0 9 8 7 6 5 4 3 2 1 pairs 9 9 4 9 3 2 2 4 1 9 1 5 1 3 1 1 1 0 9 8 7 1 2 1 0 1 6 1 5 1 6 1 7 3 8 2
Thus the solution is 4 9 5 0 − 3 8 2 = 4 5 6 8 .