Skip to content

Instantly share code, notes, and snippets.

@Zelakolase
Last active January 17, 2020 22:33
Show Gist options
  • Save Zelakolase/d16ede57593aca94701a8be67abb2beb to your computer and use it in GitHub Desktop.
Save Zelakolase/d16ede57593aca94701a8be67abb2beb to your computer and use it in GitHub Desktop.
Java code to solve Quadratic Trinomials by Factorization
public class HelloWorld{
// formula: x^2+dx+c, You gonna input d and c
public static void main(String []args){
double b=1;
double c=12;
double d=-8;
for(double a=-2147483647;a<2147483647;a++) {
if(a==0) {
a++;
}
b=c/a;
if(b+a==d) {
if (a*b==c) {
result(a,b);
}else {}
}else {}
}
}
public static void result(double x,double y) {
System.out.println("x^2+"+x+"x+"+y);
System.out.println("(x+"+x+")(x+"+y+")");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment