1
$\begingroup$

How to express $2012$ in terms of three consecutive primes

if you can use each prime number only once ?

Source of this problem you can find on this page .

Closest number to the $2012$ which I managed to express is :$2036$

$2036=509\cdot(503-499)$

P.S.

You can use only elementary operations .

  • 5
    661+673+677=2011, everything closer is a solution.2012-01-18
  • 0
    The closest I could get was $43\cdot 47-41=1980$2012-01-18
  • 2
    What operations are elementary? $$\lfloor\sqrt[(4048243-4048241)]{4048229}\rfloor$$ presumably doesn't count?2012-01-18
  • 0
    Seems impossible with only $+$, $-$, $\times$, $\div$. But 2029 + 2039 - 2053 = 2015 is also close.2012-01-18
  • 0
    @PeterTaylor,[functions](http://mathworld.wolfram.com/FloorFunction.html) are not allowed...2012-01-18
  • 2
    @pedja, $+$ is a function.2012-01-18
  • 3
    $2017-\sqrt{2027-2011}=2013$. Note that several people in the thread you link to have unsuccessfully tried their hand at this, and the thread nowhere implies that there is a solution. I've checked by computer that there's no solution using only the four basic arithmetic operations.2012-01-18
  • 0
    @joriki,Then, you can post your program as an answer...2012-01-18
  • 1
    If you can only use the four basic operations, then you are certainly not going to be able to use division, so you are restricted to the operators $+,-,\times$2012-01-18
  • 0
    List of prime numbers could be useful: http://en.wikipedia.org/wiki/List_of_prime_numbers2012-01-18
  • 1
    The only solution on the linked page is $2012 = 2011 + \lfloor{2027/2017}\rfloor$; you can't do it with more basic operations than that.2012-01-18
  • 1
    $$2012=\left(\frac{521-509}{509-503}\right) \cdot \left(\frac{521-509}{509-503}\right) \cdot 503$$2012-01-18

1 Answers 1

6

As Thomas has pointed out, if only the four basic arithmetic operations are allowed, then we can't use division: The division can't be the first operation, since there would be no way to get back to an integer afterwards; and it can't be the second operation, since that wouldn't yield an integer if the first operation was multiplication and wouldn't yield $2012$ if the first operation was additive, by Bertrand's postulate.

The two operations can't both be additive because the result would be an odd number. They can also not both be multiplications, since $2012=4\cdot503$, which isn't the product of three consecutive primes. Thus we must have one multiplication and one additive operation. The multiplication must come first since otherwise it would have to be of the form $2\cdot 1006$ or $4\cdot503$, and $1006$ cannot be generated from $3$ and $5$ and $4$ cannot be generated from primes consecutive with $503$. Thus the representation would have to be of the form $pq\pm r$. Again by Bertrand's postulate it suffices to check primes below $2012$.

The following code checks that there is no solution of this form:

import java.util.Random; import java.util.Arrays;  public class Question100122 {     final static int target = 2012;     final static int n = target;     static boolean [] prime = new boolean [n / 2]; // prime [i] : is 2i + 1 prime?                                                                                                                                                                                      public static void main (String [] args) {         Arrays.fill (prime,true);          // calculate the primes we need                                                                                                                                                                                                                                    int limit = (int) Math.sqrt (n); // highest factor to test                                                                                                                                                                                                         for (int p = 3;p <= limit;p += 2) // loop over odd integers                                                                                                                                                                                                            if (prime [p >> 1])            // only test primes p                                                                                                                                                                                                                   for (int k = 3*p;k < n;k += 2*p) // loop over odd multiples of p                                                                                                                                                                                               prime [k >> 1] = false;      // sieve them out                                                                                                                                                                                                      // extract them into an array         int nprimes = 0;         int [] primes = new int [prime.length];         primes [nprimes++] = 2;         for (int p = 3;p >> 1 < prime.length;p += 2)             if (prime [p >> 1])                 primes [nprimes++] = p;          // check all expressions of the form pq +- r         for (int np = 0;np < nprimes - 2;np++)             for (int i1 = 0;i1 < 3;i1++)                 for (int i2 = 0;i2 < 3;i2++)                     if (i2 != i1) {                         int i3 = 3 - i1 - i2;                         int v1 = primes [np + i1];                         int v2 = primes [np + i2];                         int v3 = primes [np + i3];                         if (v1 * v2 + v3 == target)                             System.out.printf ("%d * %d + %d = %d\n",v1,v2,v3,target);                         else if (v1 * v2 - v3 == target)                             System.out.printf ("%d * %d - %d = %d\n",v1,v2,v3,target);                     }     } } 
  • 1
    There's no need to check so many cases. You just need to consider the consecutive primes 41, 43, 47, 53. 41*47=1927 is far too small, 43*53=2279 is far too large, and while 43*47=2021 is quite close, 9 is neither 41 nor 53.2012-01-18
  • 0
    @Peter: Quite true :-)2012-01-18