# A math problem for the gurus

7 views

Jun 3, 2009, 11:30:02 AM6/3/09
to Recreational Computer Science Society
Okay, I have a little math problem for those on the list to try their
hand at as I'm more than a bit rusty at solving systems of equations.

Very simply: given an integer N, find w, h, c (all integers) such
that:

w = N * c
w / h = 8.5 / 11
w % c = 0
h % c = 0

The last two are intended as meaning both w and h are evenly divisible
by c. They're also the ones that are messing with me. When I took a
stab at this I rewrote those two as:

w = ac
h = bc

where a and b are some integers, but then you have a system with 5
variables and only 4 equations. And I have no idea how to impose that
the solutions MUST be integer values (real values are not useful).

The idea is I need a solution such that I could write it up as a
subroutine in Perl, ie:

{
my (\$N) = shift;

..... code here to assign values to \$w, \$h, \$c .....

return (\$w, \$h, \$c)
}

Thanks.

### Paul Nienaber

Jun 3, 2009, 11:43:38 AM6/3/09
I believe the answer here is that 17 and 22 are relatively prime (i.e.
GCF == 1, so there is no smaller pair of integers that have the same
ratio), so you're going to end up with w and h being multiples of those
(with c as their other factor), respectively. Of course, I just woke
up, so YMMV.

~p

### Noel Burton-Krahn

Jun 3, 2009, 12:36:36 PM6/3/09
w=ac
h=bc
w/h = 8.5/11
ac/bc = 8.5/11
a/b = 8.5/11
a = 8.5/11 b
a = 17/22 b

So, given an integer N:

w = 17 N
h = 22 N

(c is always 17)

~Noel

Jun 3, 2009, 6:22:47 PM6/3/09
to Recreational Computer Science Society
Nice, thanks!

I can't believe I didn't get that myself. I blame the 30 degree
heat. :p

Thanks again,

On Jun 3, 9:36 am, Noel Burton-Krahn <n...@burton-krahn.com> wrote:
> w=ac
> h=bc
> w/h = 8.5/11
> ac/bc = 8.5/11
> a/b = 8.5/11
> a = 8.5/11 b
> a = 17/22 b
>
> So, given an integer N:
>
> w = 17 N
> h = 22 N
>
> (c is always 17)
>
> ~Noel
>

Jun 3, 2009, 6:36:34 PM6/3/09
to Recreational Computer Science Society
I spoke too soon, there is a problem with that solution: h isn't
divisible by c for all values of N.

Counterexample: given N = 20, we get:

w = 17 * 20 = 340
h = 22 * 20 = 440
c = 17

but then:

h % c = 440 % 17 = 15, not 0.

I tried with values for N from 1 through 100 and the only time h was
divisible by c was when N was a multiple of 17 (so 17, 34, 51, etc).

### Paul Nienaber

Jun 3, 2009, 6:54:01 PM6/3/09
Noel's solution is on crack. c = 20 here, as in your original example.
His solution got the two (c and N; N = 17, c = some arbitrary integer)
mixed up, but is otherwise correct. Both are % 20; w = c * 17, h = c *
22, and obviously either % c = 0 for all c.

~p

Jun 3, 2009, 7:37:28 PM6/3/09
to Recreational Computer Science Society
I'm not sure I quite followed you there, but I think you said it
should be:

w = c * 17
h = c * 22

and c can be any value you want. But then that means the solution is
completely independent of the argument N. So then the rule:

w = N * c

does not hold in all cases (in fact the only time it holds is when N =
17). Or am I missing something from your explanation?

### Paul Nienaber

Jun 3, 2009, 7:57:47 PM6/3/09