Skip to content

Instantly share code, notes, and snippets.

@joriki
Created August 4, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joriki/7f8a24677624688ff68b to your computer and use it in GitHub Desktop.
Save joriki/7f8a24677624688ff68b to your computer and use it in GitHub Desktop.
Search for "small" solutions of a + b + c = abc = 6; see http://math.stackexchange.com/questions/1384653.
public class Question1384653 {
final static Rational six = new Rational (6);
public static void main (String [] args) {
for (int suma = 2;;suma++) {
System.out.println ("sum " + suma);
for (int pa = 1,qa = suma - 1;pa < suma;pa++,qa--)
if (Rational.gcd (pa,qa) == 1)
for (int signa = -1;signa <= 1;signa += 2) {
Rational a = new Rational (signa * pa,qa);
for (int sumb = 2;sumb <= suma;sumb++)
for (int pb = 1,qb = sumb - 1;pb < sumb;pb++,qb--) {
if (Rational.gcd (pb,qb) == 1)
for (int signb = -1;signb <= 1;signb += 2) {
Rational b = new Rational (signb * pb,qb);
Rational c = six.subtract (a).subtract (b);
if (a.multiply (b).multiply (c).equals (six))
System.out.println (a + " " + b + " " + c);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment