Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    4
    ReputationRep:
    Got it. Zacken could you close this please

    Question was:

    There is exactly one Pythagorean triplet for which a + b + c = 1000
    Find the product of abc
    Offline

    20
    ReputationRep:
    Oh ok nm
    • Thread Starter
    Offline

    4
    ReputationRep:
    (Original post by Bobjim12)
    Oh ok nm
    Feel free to share your solution
    Offline

    20
    ReputationRep:
    (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
    • Thread Starter
    Offline

    4
    ReputationRep:
    (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
    Offline

    20
    ReputationRep:
    (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!!
    Offline

    22
    ReputationRep:
    (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.
    Offline

    20
    ReputationRep:
    (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
    • Thread Starter
    Offline

    4
    ReputationRep:
    (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; 
          } 
        } 
     }
    Offline

    20
    ReputationRep:
    (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?
    • Thread Starter
    Offline

    4
    ReputationRep:
    (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 a^{2}+b^{2}=c^{2} and one for c = n - a - b

    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 :rofl:
    Give me a sec.

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

    Though it would return it as a double (i.e)
    Code:
    System.out.println(Math.pow(2, 2));
    would return 4.0
    Offline

    20
    ReputationRep:
    (Original post by edothero)
    I think if I combine it with the if statement then I would need two of them! One for a^{2}+b^{2}=c^{2} and one for c = n - a - b

    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!
    Offline

    22
    ReputationRep:
    (Original post by Bobjim12)

    how do indices work in Java? does 2**2 = 4?
    I think the usual thing is Math.Pow(a, b).
    Offline

    20
    ReputationRep:
    (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.
    • Thread Starter
    Offline

    4
    ReputationRep:
    (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
    Offline

    22
    ReputationRep:
    (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.
    Offline

    18
    ReputationRep:
    (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?
    Offline

    20
    ReputationRep:
    Splendid, well, this was fun haha!
    Offline

    22
    ReputationRep:
    (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.
    Offline

    18
    ReputationRep:
    (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.
    Cheers Good thread, this!
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

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

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.