equation solver

Recommended Posts

How do I solve the equation:

210x+65y=5

x and y must be integers

Share on other sites

One: Have you posted this in the right place? I don't think this forum solves algebra...

You'll need another equation to be able to solve that absolutely, but in integer terms

`x = 13n + 9, y = -42n - 29, n ∈ ℤ`
Edited by Funce

Share on other sites

yes, it's needed to be solved by js

Share on other sites

Could you describe what inputs and outputs you are expecting?

Share on other sites

It's a part of a more complex task. 5 is already a result, it is a GCD (greatest common divisor) of those 2 integers (210,65). They are function input parameters, but now it has to return x and y, not only GCD.

Share on other sites

Are you sure this is solvable, there's too little data for me to figure,

`ax + by = gcd(a, b) where a = 210, b = 65`

Creates a geometric line of 42x + 13y = 1.

You're going to need another equation to solve this one. There's a missing piece.

Share on other sites

You loop through values that can be divided into both without a remainder  storing both in individual arrays from lowest value (65), then loop through both arrays from highest till match is found then break loop, that will be gcd(5).

The remaining value can be retrieved by dividing

210 / 5 = 42

65 / 5 = 13

Edited by dsonesuk

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.