Last active
August 29, 2015 14:16
-
-
Save danleyb2/ba64f9e90c0deaaa297d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is a simple script that takes in two value, the product and sum of two numbers in a | |
//quadratic equation and tries to solve for the values to be used in solving the equation | |
function PpSp(p,s){ | |
big:for (var i=1;i<p;i++){ | |
for(var j=1;j<p;j++){ | |
if ((i*j)==p){ | |
if ((i+j)==s){ | |
// System.out.println("I got it. The numbers are "+i+" and "+j); | |
break big; | |
} | |
} | |
} | |
if (i==(p-1)){ | |
System.out.println("There is no solution for this one"); | |
} | |
} | |
} | |
function PpSn(p,s){ | |
big:for (var i=-1;i>=(p*-1);i--){ | |
for (var j=-1;j>(p*-1);j--) { | |
if ((i*j)==p){ | |
if (i+j==s){ | |
//Sys | |
break big; | |
} | |
} | |
} | |
} | |
} | |
function PnSn(p,s){ | |
big:for (var i=1;i<Math.abs(p);i++){ | |
for (var j=1;j<Math.abs(p);j++){ | |
if ((j*i)==Math.abs(p)){ | |
//int t=j*-1; | |
if (i>j){ | |
i=(i*-1); | |
if ((i+j)==s){ | |
// " + j); | |
break big;} | |
}else { | |
j = (j * -1); | |
if ((i + j) == s) { | |
//System.out.println(i + " " + j); | |
break big; | |
} | |
} | |
} | |
} | |
} | |
} | |
function PnSp(p,s){ | |
big:for (var i=1;i<Math.abs(p);i++){ | |
for (var j=1;j<Math.abs(p);j++){ | |
if ((j*i)==Math.abs(p)){ | |
if (i<j){ | |
i=(i*-1); | |
if ((i+j)==s){ | |
//System.out.println(i + " " + j); | |
break big;} | |
}else { | |
j = (j * -1); | |
if ((i + j) == s) { | |
//System.out.println(i + " " + j); | |
break big; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment