public class Ptrips {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int n = 1000;
boolean solution = false;
for(a = 1; a < n; a++){
for(b = a; b < n; b++) {
c = n - a - b;
if ((a*a) + (b*b) == (c*c)) {
solution = true;
break;
}
}
if(solution){
System.out.println(a + ", " + b + " and " + c);
break;
}
}
}
public class Ptrips {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int n = 1000;
solution = false;
for(a = 1; a < n; a++){
for(b = a; b < n; b++) {
c = n - a - b;
if ((a*a) + (b*b) == (c*c)) {
solution = true;
break;
}
}
if(found){
System.out.println(a + ", " + b + ", " + c);
break;
}
}
}
if((c = n - a - b) && (a*a + b*b == c*c)) {
solution = true;
break;
}
Which would definitely be more efficient, good spot!Math.pow(n, n1)
Which would return System.out.println(Math.pow(2, 2));
would return 4.0if((c = n - a - b) && (a*a + b*b == c*c)) {
solution = true;
break;
}
Last reply 3 minutes ago
LSE International Social and Public Policy and Economics (LLK1) 2024 ThreadPosted 3 minutes ago
Failed 2 out of 3 exams semester 1 and scared about the 3 I have left in semester 2.Last reply 7 minutes ago
Official Dental Hygiene and Therapy (Oral Health Science) 2024 Entry Thread2927
Last reply 9 minutes ago
Official London School of Economics and Political Science 2024 Applicant ThreadLast reply 22 minutes ago
University of Oxford 2025 Undergraduate Applicants Official ThreadLast reply 1 hour ago
Official University of Edinburgh Applicant Thread for 2024Last reply 1 day ago
Did Cambridge maths students find maths and further maths a level very easy?Last reply 2 weeks ago
Edexcel A Level Mathematics Paper 2 unofficial mark scheme correct me if wrong71
Last reply 1 day ago
Did Cambridge maths students find maths and further maths a level very easy?Last reply 2 weeks ago
Edexcel A Level Mathematics Paper 2 unofficial mark scheme correct me if wrong71