Pythagorean triples/Java/Brute force primitives: Difference between revisions

This is what I was really looking for when I made that last optimization
(Another slight speedup)
(This is what I was really looking for when I made that last optimization)
Line 85:
for(BigInteger b = a.add(ONE);
b.compareTo(peri2) < 0; b = b.add(TWO)){
//onlyskip oneif both or neither of a and b can beare divisible by each of 3 and 4
if(amod3 &&== b.mod(B3).equals(ZERO)) continue;||
//only one of a and b can beamod4 divisible== byb.mod(B4).equals(ZERO)) 4continue;
if(amod4 && b.mod(B4).equals(ZERO)) continue;
//if a^2 + b^2 is not a perfect square then don't even test for c's
BigInteger aabb = aa.add(b.multiply(b));
Line 95 ⟶ 94:
(aabb.and(B127).intValue() != 16) &&
(aabb.and(B191).intValue() != 0)) continue;
if(a.multiply(b).mod(B12).compareTo(ZERO) != 0) continue;
BigInteger ab = a.add(b);
 
Anonymous user