java - Why does this condition always return false? -


could please tell me wrong following code. doesn't show result.

the integer a,b,c side of right angle triangle.(was solving project euler problem 39)

if use || in place of && , shows desired result based on || condition. doesn't work && condition

public static void main(string[] args)  {     int a,b,c;     (a=1;a<120;a++){         for(b=120;b>0;b--){             c= 120-(a+b);             if (((c) > (a+b)) && ((c*c)==(a*a)+(b*b))){                     system.out.println(a + " , " + b +" , " + c);                     system.out.println("**************");                  }             }            }     } 

quite simply, it's because expression:

((c) > (a+b)) 

...never returns true in example valid right angled triangles, , since && condition requires both operands evaluate true, if statement isn't executed.

you can see quite if put in following lines:

system.out.println("c: " + c); system.out.println("a+b: " + a+b); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -