Is there any way to solve this problem without having to do it by hand?

141 Views Asked by At

I'm dealing with the following problem in computational programming. I'm trying to find a way to build an algorithm that can quickly resolve the following problem statement. Is there any way to group the relations below, or to find values of y in the following problem statement very efficiently without having to do it by hand?

Problem: Given an integer value x, where x > 2, is there any integer value y, where y >= 0, such that x satisfies any of these relations for some integer k, where k > 0?

[1]: y = (x - 2k)/(20k)
[2]: y = (x - 6k)/(20k)
[3]: y = (x - 14k)/(20k)
[4]: y = (x - 18k)/(20k)

Example #1: If x = 4:

From [1]: y = (4 - 2k)/(20k) = 0 for k = 2.

Example #2: If x = 6:

From [1]: y = (6 - 2k)/(20k) = 0 for k = 3.

Example #3: If x = 3:

From [1]: y = (3 - 2k)/(20k) ... k = 1 => y = (3 - 2(1))/(20(1)) = 1/20, which would not be an integer ... k = 2 => y = (3 - 2(2))/(20(2)), which would be negative. It would be negative for any k > 1.
From [2]: y = (3 - 6k)/(20k) ... It would be negative for any k > 0.
From [3]: y = (3 - 14k)/(20k) ... It would be negative for any k > 0.
From [4]: y = (3 - 18k)/(20k) ... It would be negative for any k > 0.

We can deduce that for x = 3, there is no value y that satisfies any of the above relations.
2

There are 2 best solutions below

2
On BEST ANSWER

As stated, the problem has a very simple answer. If $x$ is even, relation [1] is satisfied if you let $y=0$ and $k=x/2$. If $x$ is odd, none of the relations can be satisfied, since they all imply that $x$ is even -- i.e., they can be rewritten as saying $x=2k(10y+r)$ with $r=1$, $3$, $7$, or $9$.

1
On

The most restrictive is [4], which tells you that $$ x = 2 (10 k y + 9) $$ So $x$ is even, and moreover $$ \frac{1}{10} \left( \frac{x}{2} - 9 \right) = k y $$ has to be an integer, i.e. for some integer $c$: $$ x = 20 c + 18 $$ This will comply with [4], and also [1] and [2]. [3] can be handled similarly, combining with this will give a way to comply with all four.