7 views

Skip to first unread message

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:

sub solveAdamsStupidMathProblem

{

my ($N) = shift;

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

return ($w, $h, $c)

}

Thanks.

Adam

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:

sub solveAdamsStupidMathProblem

{

my ($N) = shift;

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

return ($w, $h, $c)

}

Thanks.

Adam

Jun 3, 2009, 11:43:38 AM6/3/09

to recco...@googlegroups.com

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

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

Jun 3, 2009, 12:36:36 PM6/3/09

to recco...@googlegroups.com

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

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,

Adam

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

>

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

heat. :p

Thanks again,

Adam

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).

Adam

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).

Adam

Jun 3, 2009, 6:54:01 PM6/3/09

to recco...@googlegroups.com

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

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?

Adam

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

17). Or am I missing something from your explanation?

Adam

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

to recco...@googlegroups.com

N = 17, per your original expressions.

What comes of that is that when w = N * c (c being the intended factor

of both w and h, per your %c==0 assertions), and per your description

w/h = 8.5/11 therefore h = (11/8.5)w and therefore (by substitution for

w and then for N) h = 22c. So N is one of two useful numbers here: 17

and 22.

~p

What comes of that is that when w = N * c (c being the intended factor

of both w and h, per your %c==0 assertions), and per your description

w/h = 8.5/11 therefore h = (11/8.5)w and therefore (by substitution for

w and then for N) h = 22c. So N is one of two useful numbers here: 17

and 22.

~p

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu