You are Here: Home >< Maths

# Pythagorean triplets. watch

1. Got it. Zacken could you close this please

Question was:

There is exactly one Pythagorean triplet for which
Find the product of
2. Oh ok nm
3. (Original post by Bobjim12)
Oh ok nm
Feel free to share your solution
4. (Original post by edothero)
Feel free to share your solution
Oh no, i wasn't really on a solution, i wasn't too sure what you were looking for so i was trying to clarify it, but i guess it doesn't matter anymore XD
5. (Original post by Bobjim12)
Oh no, i wasn't really on a solution, i wasn't too sure what you were looking for so i was trying to clarify it, but i guess it doesn't matter anymore XD
Lmao yeah xD the solution is
a = 200
b = 375
c = 425

a^2 + b^2 = c^2
and
a+b+c = 1000
6. (Original post by edothero)
Lmao yeah xD the solution is
a = 200
b = 375
c = 425

a^2 + b^2 = c^2
and
a+b+c = 1000
How did you get it? I like seeing code!!
7. (Original post by edothero)
Got it. Zacken could you close this please
I'll leave it open for the moment - looks like some people are interested in it.
8. (Original post by Zacken)
I'll leave it open for the moment - looks like some people are interested in it.
heeeeeeeeey, i'm just curious
9. (Original post by Zacken)
I'll leave it open for the moment - looks like some people are interested in it.
That's fine, thank you anyway .

(Original post by Bobjim12)
How did you get it? I like seeing code!!
Here's the code: I used Java.
Code:
```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;
}
}
}```
10. (Original post by edothero)
Thanks fine, thank you anyway .

Here's the code: I used Java.
Code:
```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;
}
}
}```
Ok, i did misunderstand what you were asking,

I'm not sure if it would work but instead of having the c = n- a -b statement you could combine that with the if statement, if you want it to be slightly more efficient but if it works you probably don't want to bother!

how do indices work in Java? does 2**2 = 4?
11. (Original post by Bobjim12)
Ok, i did misunderstand what you were asking,

I'm not sure if it would work but instead of having the c = n- a -b statement you could combine that with the if statement, if you want it to be slightly more efficient but if it works you probably don't want to bother!

how do indices work in Java? does 2**2 = 4?
I think if I combine it with the if statement then I would need two of them! One for and one for

The only other thing I can think of atm is
Code:
```if((c = n - a - b) && (a*a + b*b == c*c)) {
solution = true;
break;
}```
Which would definitely be more efficient, good spot!

As for the indices thing, I'm not quite sure you know
Give me a sec.

Aha, got it; unlike languages like Python you can't do a**b for
You need to use
Code:
`Math.pow(n, n1)`
Which would return

Though it would return it as a double (i.e)
Code:
`System.out.println(Math.pow(2, 2));`
would return 4.0
12. (Original post by edothero)
I think if I combine it with the if statement then I would need two of them! One for and one for

The only other thing I can think of atm is
Code:
```if((c = n - a - b) && (a*a + b*b == c*c)) {
solution = true;
break;
}```
That.should work, if i am in the right frame of mind right now!
13. (Original post by Bobjim12)

how do indices work in Java? does 2**2 = 4?
I think the usual thing is Math.Pow(a, b).
14. (Original post by Zacken)
I think the usual thing is Math.Pow(a, b).
Hmm, that is interesting.

you could then just do Math.Pow(n-a-b, 2)

Assuming i am getting the args right.
15. (Original post by Bobjim12)
That.should work, if i am in the right frame of mind right now!
Check the post again, I've made a few edits
Zacken has beat me to it though, the guys unstoppable
16. (Original post by Bobjim12)
Hmm, that is interesting.

you could then just do Math.Pow(n-a-b, 2)

Assuming i am getting the args right.
That would be (n-a-b)^2, yeah.
17. (Original post by Zacken)
That would be (n-a-b)^2, yeah.
Slightly off topic but do you know if you do much using programming in the Cambridge maths course?
18. Splendid, well, this was fun haha!
19. (Original post by Student403)
Slightly off topic but do you know if you do much using programming in the Cambridge maths course?
Very little in terms of using MatLab for a lengthy computation project in second and third years called "Catam", details should be available online, I think.
20. (Original post by Zacken)
Very little in terms of using MatLab for a lengthy computation project in second and third years called "Catam", details should be available online, I think.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: February 20, 2016
Today on TSR

### Tuition fees under review

Would you pay less for a humanities degree?

### Buying condoms for the first time - help!

Discussions on TSR

• Latest
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams

## Groups associated with this forum:

View associated groups
Discussions on TSR

• Latest

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE