You're going to need to generalize!

What is the sum of all positive integers less than 1 0 4 10^4 which are relatively prime to 1 0 4 ? 10^4?


The answer is 20000000.

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.

11 solutions

Zee Ell
Aug 2, 2017

Since 10000 = 1 0 4 = 2 4 × 5 4 , therefore exactly those integers will be \text {Since } 10000 = 10^4 = 2^4 × 5^4 \text { , therefore exactly those integers will be}

coprime to 10000, which are neither divisible by 2 nor divisible by 5. \text {coprime to 10000, which are neither divisible by 2 nor divisible by 5. }

Hence, we can get our sum S by applying PIE (the principle of inclusion-exclusion) and the sum of the arithmetic sequence formula:

S = 10000 × 10001 2 2 × 5000 × 5001 2 5 × 2000 × 2001 2 + 10 × 1000 × 1001 2 = S = \frac { 10000×10001 }{ 2 } - 2 × \frac { 5000×5001 }{ 2 } - 5 × \frac { 2000×2001 }{ 2 } + 10 × \frac { 1000×1001 }{ 2 } =

= 20000000 = \boxed { 20000000 }

Remarks:

1.) For the sake of simplicity, we summed the integers till 10000 (despite the question says < 10000), but we filtered the 10000 out (since it is not coprime to itself), so we got the correct result in the end.

2.) It is not necessary to generalise in order to solve a simple case like this (where we have no more than 2 prime factors). However, in cases where we have (more than) 3 prime factors, we might be better off by using Euler's Totient Function (see the solutions of Alex G and Zach Abueg regarding this).

That is basically the way I did it, although I am happy to learn about Euler's totient function! I didn't realize at first that 1 is counted as coprime to every number, so I originally had 19,999,999.

Mark Lama - 3 years, 10 months ago

I had basically the same idea. 10^4 = 2^4 5^4 All numbers less than 10^4 coprime to that can contain no 2 or 5. All numbers divisible by 2 or 5 cycle by groups of 10 numbers, and only those ending in 1,3,7,9 are coprime. Each group adds 1+3+7+9=20 plus its offset from 0. That's 20 10^3=20000 for the last digit and S=0+10+...+9990=9990*1000/2=4995000 for the offsets. So 5015000. Clearly I'm missing something.

Jack Sparrow - 3 years, 9 months ago

Log in to reply

I feel that your approach might be closer to Andy Hayes' solution. See the correct version there.

Zee Ell - 3 years, 9 months ago

Log in to reply

Ya, I figured it out after I posted, but couldn't find a way back to the question. I just missed the part where the collective sum of offsets from 0 happens 4 times. Got 20,000,000.

Jack Sparrow - 3 years, 9 months ago

Again, if you know what the phrase “relatively prime to 10^4” means then you know how to work to the answer. If not, then the question is frustrating and abstruse... and reading your answer does not inform.

David Brown - 3 years, 7 months ago

Seems easier to not include 10000 since you then get simpler multiplications.

D B - 3 years, 2 months ago
Zach Abueg
Aug 2, 2017

Relevant wiki: Euler's Totient Function

The sum S S of all positive integers less than n n and relatively prime to n n is n ϕ ( n ) 2 n > 2 \dfrac{n \phi (n)}{2} \ \forall \ n > 2 .

Proof:

If k { 1 , , n 1 } k \in \big \{1, \ldots , n - 1\big \} is relatively prime to n n , then so is n k n - k , so the integers that are being summed up can be combined into ϕ ( n ) 2 \dfrac{\phi (n)}{2} pairs whose members sum to n n . If n > 2 n > 2 , n 2 \dfrac n2 is never relatively prime to n n , so we must have pairs { k , n k } \big \{k, n - k \big \} .

Now, a number n n with prime factorization

n = p 1 q 1 p 2 q 2 p k q k n = p_1^{q_1}p_2^{q_2} \cdots p_k^{q_k}

will have

ϕ ( n ) = n ( 1 1 p 1 ) ( 1 1 p 2 ) ( 1 1 p k ) \displaystyle \phi (n) = n\left(1 - \frac{1}{p_1}\right)\left(1 - \frac{1}{p_2}\right) \cdots \left(1 - \frac{1}{p_k}\right)

positive integers less than n n that are relatively prime to n n . With that in mind, we solve for n = 1 0 4 n = 10^4 .

1 0 4 = 2 4 × 5 4 ϕ ( 1 0 4 ) = 1 0 4 ( 1 1 2 ) ( 1 1 5 ) = 4 × 1 0 3 S = 1 0 4 × 4 × 1 0 3 2 = 2 × 1 0 7 \displaystyle \begin{aligned} 10^4 & = 2^4 \times 5^4 \\ \implies \phi \left(10^4\right) & = 10^4 \left(1 - \frac 12\right)\left(1 - \frac 15\right) = 4 \times 10^3 \\ \implies S & = \frac{10^4 \times 4 \times 10^3}{2} = \boxed{2 \times 10^7} \end{aligned}

Excellently done

revanth revanth - 3 years, 10 months ago

Log in to reply

Thank you :)

Zach Abueg - 3 years, 10 months ago
Andy Hayes
Aug 8, 2017

I think the approach of @Zee Ell approach is best, but here is an alternative approach.

The numbers which are relatively prime to 1 0 4 10^4 will satisfy:

n 1 , 3 , 7 , 9 ( m o d 10 ) . n \equiv 1,3,7,9 \pmod{10}.

They will be of the forms:

n = 10 k + 1 , 10 k + 3 , 10 k + 7 , 10 k + 9 n = 10k+1, \quad 10k+3, \quad 10k+7, \quad 10k+9

for some integer k , k, 0 k 999. 0\le k \le 999. Summing all of these integers gives:

S = k = 0 999 ( 10 k + 1 ) + k = 0 999 ( 10 k + 3 ) + k = 0 999 ( 10 k + 7 ) + k = 0 999 ( 10 k + 9 ) = k = 0 999 ( 40 k + 20 ) = 40 ( 999 1000 2 ) + 20 ( 1000 ) = 20000000 \begin{aligned} S &= \sum\limits_{k=0}^{999}(10k+1)+\sum\limits_{k=0}^{999}(10k+3)+\sum\limits_{k=0}^{999}(10k+7)+\sum\limits_{k=0}^{999}(10k+9) \\ &= \sum\limits_{k=0}^{999}(40k+20) \\ &= 40\left(\frac{999 \cdot 1000}{2}\right) + 20(1000) \\ &= \boxed{20000000} \end{aligned}

Why are all the numbers relatively prime to 10^4 of this form?

Agnishom Chattopadhyay - 3 years, 9 months ago

Log in to reply

All numbers can be written as the multiple of some number, k, + the remainder when divided by k. So all numbers divisible by 10 are of the form 10k, 10k+1, 10k+2..... 10k+9. So all numbers which are divisible by 2 in this form would be: 10k, 10k+2, 10k+4..... 10k+8. And all numbers divisible by 5 would be 10k, 10k+5. Since trying to divide 2 or 5 into any of the other forms would lead to a remainder. Hence, all the other forms are not divisible by 2 or 5.

Mo H - 3 years, 9 months ago

Elegant solution...👌

Ben John Toms - 3 years, 6 months ago
Alex G
Aug 2, 2017

To solve this problem, we find the general formula for the sum of positive integers less than n n which are relatively prime to n n .

Let gcd ( a , b ) \text{gcd}(a,b) denote the greatest common divisor of two integers a a and b b .

From the wiki, we know that gcd ( c , d ) = gcd ( c , c d ) \text{gcd}(c,d) =\text{gcd}(c,c-d) for integers d < c d < c .

In order to make the notation more manageable, let us consider the sequence of integers less than some number n n which are relatively prime to n n . Let us call this sequence C C , and let it be the sequence:

c 0 , c 1 , c 2 , c ϕ ( n ) 2 , c ϕ ( n ) 1 c_0, c_1 , c_2, \ldots c_{\phi(n)-2} , c_{\phi(n)-1}

Note that there are exactly ϕ ( n ) \phi(n) ( ϕ ( n ) \phi(n) is the totient function) integers in C C by the definition of the totient.

We are now trying to find a closed form for the sum S S :

i = 0 ϕ ( n ) 1 c i \sum_{i=0}^{\phi(n)-1} c_i

By definition, gcd ( n , c i ) = 1 \text{gcd}(n,c_i) = 1 for all 1 i ϕ ( n ) 1 1 \leq i \leq \phi(n)-1 (the definition of relatively prime integers). Also by definition, the sequence includes all integers c < n c < n such that gcd ( n , c ) = 1 \text{gcd}(n,c) = 1 . We know that gcd ( n , n c i ) = gcd ( n , c i ) = 1 \text{gcd}(n,n-c_i)=\text{gcd}(n,c_i) =1 and that n c i < n n-c_i < n , hence n c i n-c_i must be in the sequence C C . In fact, it must be true that n c i = c ϕ ( n ) 1 i n-c_i = c_{\phi(n)-1-i} .

For a concrete example, consider n = 9 n=9 . The sequence C C would be:

1 , 2 , 4 , 5 , 7 , 8 1,2,4,5,7,8

The sequence has length 6 = ϕ ( 9 ) 6 = \phi(9) . It is apparent that 9 1 = 8 9-1 = 8 , 9 2 = 7 9-2 = 7 , 9 4 = 5 9-4 = 5 , 9 5 = 4 9-5 = 4 , 9 7 = 2 9-7 = 2 , 9 8 = 1 9-8 = 1 , which is equivalent to saying that n c i = c ϕ ( n ) 1 i n-c_i = c_{\phi(n)-1-i} for all c i c_i in C C .

We now rewrite C C as

c 0 , c 1 , c 2 n c 2 , n c 1 , n c 0 c_0, c_1, c_2 \ldots n-c_2, n-c_1, n-c_0

We can now rewrite S S as:

S = i = 0 ϕ ( n ) c i = c 0 + c 1 + c 2 + + n c 2 + n c 1 + n c 0 = c 0 c 0 + c 1 c 1 + c 2 c 2 + + n + n = n + + n S = \sum_{i=0}^{\phi(n)} c_i = c_0+c_1+c_2 + \ldots + n-c_2 + n-c_1 + n-c_0 = c_0 -c_0 + c_1 - c_1 + c_2 -c_2 + \ldots + n + n = n + \ldots + n

Where n n is repeated exactly ϕ ( n ) 2 \dfrac{\phi(n)}{2} times. Hence,

S = n ϕ ( n ) 2 S = \dfrac{n\phi(n)}{2}

Substituting n = 1 0 4 n=10^4 ,

1 0 4 ϕ ( 1 0 4 ) 2 = 1 0 4 4000 2 = 2 1 0 7 \dfrac{10^4 \cdot \phi(10^4)}{2} = \dfrac{10^4 \cdot 4000}{2} = 2 \cdot 10^7

Uros Stojkovic
Aug 14, 2017

10000 = 2 4 × 5 4 10000=2^{4}\times 5^{4}

We are going to going to get the desired sum by subtracting sum of integers less than 10000 10000 divisible by 2 2 or 5 5 from sum of first 9999 9999 integers.

It is easy to calculate the sum of first 9999 9999 integers: k = 1 9999 k = 9999 × 10000 2 = 9999 × 5000 \sum_{k=1}^{9999}k=\frac{9999\times 10000}{2}=9999\times 5000 .

Next, sum of all even numbers less then 10000:

= 2 + 4 + 6 + 8 + . . . + 9998 = 2 ( 1 + 2 + 3 + 4 + . . . + 4999 ) = 2 × 4999 × 5000 2 = 5000 × 4999 \sum =2+4+6+8+...+9998=2(1+2+3+4+...+4999)=2\times \frac{4999\times 5000}{2}=5000\times 4999 .

Then, sum of all numbers divisible by 5 5 minus all even numbers in this group equals:

= 5 + 15 + 25 + 35 + . . . + 9995 1000 = ( 5 + 9995 ) × 1000 2 = 1000 × 5000 \sum =\underbrace{5+15+25+35+...+9995}_{1000}=\frac{(5+9995)\times 1000}{2}=1000\times 5000

(note that there are 1999 numbers divisible by 5 less than 10000, and that 999 of them are even) {\color{cyan} \text{(note that there are 1999 numbers divisible by 5 less than 10000, and that 999 of them are even)}}

Hence, desired sum is:

9999 × 5000 4999 × 5000 1000 × 5000 = 5000 ( 9999 4999 1000 ) = 5000 × 4000 = 20 , 000 , 000 9999\times 5000 - 4999\times 5000 - 1000\times 5000=5000(9999-4999-1000)=5000\times 4000=\boxed{20,000,000}

Nice approach. Neat solution.

Agnishom Chattopadhyay - 3 years, 9 months ago
Kelvin Hong
Aug 17, 2017

I solve this by a much simpler way

I first find what numbers are relatively prime to 10000 between 1 to 10 included

I find that 1,3,7,9 are relatively prime to 10000

then I concluded that every even number and also with last digit 5 or 0 are and only not relatively prime to 10000.

It is because, 10000 = 2 4 × 5 4 10000=2^4 \times 5^4

every even number has a factor 2, and every number with last digit 5 has a factor 5, and also every number with a last digit 0 has a factor 10, so these number aren't relatively prime to 10000.

so along the first four number , I get 11,13,17,19 and 21,23,27,29 and so on, until 9991,9993,9997,9999.

I add it up by summation

1000 2 ( 1 + 9991 + 3 + 9993 + 7 + 9997 + 9 + 9999 ) = 2 × 1 0 7 \frac{1000}{2}(1+9991+3+9993+7+9997+9+9999)=\boxed{2 \times 10^7}

Could you please explain what you mean here:

then I concluded that every even number and also with last digit 5 or 0 are and only relative to 10000

I didn't really get you.

Agnishom Chattopadhyay - 3 years, 9 months ago

Log in to reply

Oh, I maybe too casual to write this solution, I will write some explanation at the bottom.

Kelvin Hong - 3 years, 9 months ago

Since the factors of 10^4 are 2^4 and 5^4, The numbers relatively prime to 10^4 must be multiples of 2 or 5. We can see that any even number is a multiple of two so instead we can just find the sum of all positive odd integers less than 10^4 and remove any divisible by 5. Those that are divisible by 5 are the ones ending in 5. Thus, our answer can be Sum of Odd Numbers - Sum of Odd Numbers Ending in 5 This becomes 5000 X 10000 2 \frac{5000X10000}{2} - 1000 X 10000 2 \frac{1000X10000}{2} = 25000000-5000000 which gives a answer of 20000000

Notes: The equation was from the rule that a+(a+k)+(a+2k).....+(a+nk)= ( a + a + n k ) ( n + 1 ) 2 \frac{(a+a+nk)*(n+1)}{2}

5000 was the number of odd numbers less than 10^4 and 10000 was (1+9999)

1000 was the number of odd numbers less than 10^4 ending in 5 and 10000 was (5+9995)

Pablo Castellanos
Aug 19, 2017

As @Zee Ell pointed out we are looking for the sum of numbers below 10⁴ which are not multiples of 2 or 5. We can first add all the odd numbers below 10⁴, and then substract the odd multiples of 5 to get our answer.

As we are interested in the numbers smaller than 10⁴, the last even number we need to consider is 9999, which is the 5000th odd number (x is the x + 1 2 \frac{x+1}{2} th odd number). The sum of the first n odd numbers is n² so we get 5000²=25×10⁶. We then need to substract the odd multiples of 5 from that (5+15+25+35...). We can factor out the 5 so we end up with 5(1+3+5+7...) which is 5 times the sum of odd numbers... up to 9995 5 \frac{9995}{5} =1999, which is the 1000th odd number. So 5× that sum is 5×1000²=5×10⁶. Substract, and we end up with 20×10⁶, or 2×10⁷

Arjen Vreugdenhil
Aug 13, 2017

General solution

Consider the general case: given a positive integer N > 2 N > 2 , how much is 1 d < N , ( N , d ) = 1 d ? \sum_{1 \leq d < N,\ (N,d)=1} d\ ? The answer is 1 2 ϕ ( N ) N , \frac 12 \phi(N) N, where ϕ \phi is the Euler totient function.

Here , ϕ ( 1 0 4 ) = 1 0 3 ϕ ( 10 ) = 1 0 3 ϕ ( 2 ) ϕ ( 5 ) = 1 0 3 1 4 = 4 × 1 0 3 , \phi(10^4) = 10^3\cdot \phi(10) = 10^3 \cdot \phi(2)\cdot \phi(5) = 10^3\cdot 1\cdot 4 = 4\times 10^3, so that the answer is 1 2 4 × 1 0 3 1 0 4 = 2 1 0 7 = 20 000 000 . \frac 12\cdot 4\times 10^3 \cdot 10^4 = 2\cdot 10^7 = \boxed{20\,000\,000}.


Proof

Observe that if ( N , d ) = 1 (N,d) = 1 then ( N d , d ) = 1 (N-d,d) = 1 . (Also, N N and N d N-d are distinct numbers in this case; the only exception would be d = N / 2 d = N/2 but then ( N , d ) = N / 2 > 1 (N,d) = N/2 > 1 .)

Thus the values to be added come in pairs, and the sum of each pair is d + ( N d ) = N d + (N-d) = N . The number of pairs is half the number of values to be added; and the number of values to be added is ϕ ( N ) \phi(N) . This immediately gives (number of pairs) (sum of each pair) = 1 2 ϕ ( N ) N . \text{(number of pairs)}\cdot \text{(sum of each pair)} = \frac12\phi(N)\cdot N.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def num_factors(n, p, b):
    results = []

    for i in range(1, int(n**0.5) + 1):            
        if n % i == 0:
            if n == p:
                b.append(i)
                b.append(int(n/i))
            results.append(i)
            results.append(int(n/i))
    results = sorted(set(results))
    b = sorted(set(b))
    x = results[1:-1]
    y = b[1:-1]
    k = set(x).intersection(set(y))
   # print k

    if len(k) == 0:
        numbers.append(n)

    return numbers

#################################################################
p = 10000
prime_to = []
numbers = []

for j in range (p, 0, -1):
    l = num_factors(j, p, prime_to)

print sorted(l)

x = sum(l)
print x

[1, 3, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, ......9971, 9973, 9977, 9979, 9981, 9983, 9987, 9989, 9991, 9993, 9997, 9999]

Michael Fitzgerald - 3 years, 9 months ago

Log in to reply

Your list includes the values 2 and 5, which are prime but not relative prime to 1 0 4 10^4 .

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

Thanks Arjen. I see where I made the mistake in my coding

results[1:-1] should be x = results[1:] b[1:-1] should be b[1:]

Michael Fitzgerald - 3 years, 9 months ago
Robert DeLisle
Aug 19, 2017

This seemingly tedious chore can be done in two simple steps using two sums of consecutive odd numbers.

1 0 4 10^4 = 2 4 2^4 x 5 4 5^4

Every number less than 10,000 that is not relatively prime has a factor of 2 or 5. Those numbers consist of the even numbers and odd multiples of 5.

The problem can be solved directly by summing the odd numbers and subtracting the sum of the odd multiples of 5, both using the fact that the sums of consecutive odd numbers are perfect squares.

There are 5000 positive odd integers less than 10,000. The sum of those is 500 0 2 5000^2 = 25,000,000.

All that is necessary is to subtract the odd multiples of 5 to get the answer.

The odd multiples of 5, 5 + 15 + ,,, + 9995 = 5 x ( 1+ 3 +...+ 1999 ). Again a sum of consecutive odd numbers.

There are 1000 odd multiples of 5 less than 1 0 4 10^4 so 1+ 3 +...+ 1999 = 1000^2 = 1,000,000

The sum of the odd multiples of 5 less than 1 0 4 10^4 is 5 x 1,000,000 = 5,000,000

The solution is 25,000,000 - 5,000,000 = 20,000,000

This was a simple problem. The only numbers NOT coprime with 10,000 are the odd integers with the exception of those divisible by 5. So sum all the odd numbers from 1 to 9999. Then sum all numbers 5+15+25+.....+9995 and subtract the second sum from the first.

So, all odd integers not divisible by 5 are coprime to 10000? That is a neat observation indeed. How did you get this result?

Agnishom Chattopadhyay - 3 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...