Consider the triangles with integer sides $a$, $b$ and $c$ with $a \leq b \leq c$. An integer sided triangle $(a,b,c)$ is called primitive if $\gcd(a,b,c)=1$. How many primitive integer-sided triangles exist with a perimeter not exceeding $10 000 000$?
I am trying to solve this on Euler project. I am wondering what is the best way to go to find the valid triples for constructing a triangle. Of course, you can do nested for loops but that is not efficient. Any pointers would help.
Thanks
This is problem 276. I haven't solved it, but the first thing to realize is you don't have to loop over c-from a and b you should be able to find the number of solutions. Of course, you don't have time to loop over both a and b, but you may be able to loop over a. I would start by doing a brute force run up to 100 or 250-you should have time for that. Keep track of the number of solutions for each a. Then try to find a formula for the number of triangles that include a. This will probably be based on the factors of a.
Hope this helps. I did a lot of them, but have gotten less energetic now.