## x + x^2=90

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

### x + x^2=90

I know that in this case, x is equal to 9, but how would I figure this out mathematically?

seaBiscuit\$
Coder
Posts: 45
Joined: Sun Nov 26, 2006 2:00 pm
Location: Champaign, Illinois

### Re: x + x^2=90

{Nathan} wrote:I know that in this case, x is equal to 9, but how would I figure this out mathematically?
Looks like you have a quadratic equation thingy.

x^2 + x - 90 = 0 though that could be optimized a bit because 'a' and 'b' would be ones.
sid6.7 wrote:everytime i see your avatar i want to scream and kill it.... moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico
Nathan, I don't remember how to solve it either, but I don't thing the quadratic equation is going to help.

Yoo could use the brute force approach by writing a little program that uses a FOR loop on X, and keeps testing until it finds it. Something like this:
[code}
FOR X = 1 TO 90
T = X + X^2
IF T = 90 THEN PRINT "ANSWER = ";X : GOTIT=1 :EXIT FOR
NEXT X
[/code]

PS, I haven't tried it.

Regards..... Moneo

Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:
Yes, I think the quadratic formula would be the best way to solve it, since it works for ANY quadratic.

Code: Select all

``````PosX=(-B+SQR((B^2)-(4*A*C)))/(2*A)
NegX=(-B-SQR((B^2)-(4*A*C)))/(2*A)``````
as the quadratic formula has a plus and minus. However, if the discriminant (B^2-4AC) is negative, QB will generate an error because it has an imaginary solution.
Free Linux ISO images to burn to a CD! <? phpinfo() ?>