                                      //WELCOME TO LAB 2: COMPUTING PYTHAGOREAN TRIPLES IN C//


#include <stdio.h>
#include <math.h>


int main()
{
    /*These are the variables that will be needed to figure out and display the triple coordinate set
    since the integer values have to be positive, set largest, max_a and max_b to be 0*/
    int i=1, N, a, b, c, largest=0, max_a=0, max_b=0, count=0;

    /*Enter the integer value N*/
    printf("Please enter a positive integer:\n");
    scanf("%d", &N);
    /*Since there are no pythagorean triples in the range 0 to 5, make an if loop that will only look for triples in a range greater than 0 to 5*/
    if(N>5)

    {   /*This first loop will count the amount of triples in the range 0 to N*/
        for (c=1; c<N; c++)
        {
            for (b=1; b<c; b++)
            {
                for (a=1; a<b; a++)
                    /*Ensure that the values satisfy the equation*/
                    if ((a*a)+(b*b)==(c*c))
                    { /*If the following equation is satisfied, increase the count*/
                        count++;
                        if (c > largest)
                        {
                            /*If a larger value than c is found, set c to be the new largest value*/
                            largest = c;
                            /*Set max_a and max_b to be the a and b values in the pythagorean triple*/
                            max_a=a;
                            max_b=b;

                        }


                    }

            }
        }
        /*Print the number of pythagorean triple coordinates in the range 0 to N*/
        printf("\n\tThere are %d triples in this range\n", count);
        /*This loop will be used to show all of the triples coordinates*/
        for (c=1; c<N; c++)
        {
            for (b=1; b<c; b++)
            {
                for (a=1; a<b; a++)
                    if ((a*a)+(b*b)==(c*c))
                    {

                        if (c > largest)
                        {
                            /*If a larger value than c is found, set c to be the new largest value*/
                            largest = c;
                            /*Set max_a and max_b to be the a and b values in the pythagorean triple*/
                            max_a=a;
                            max_b=b;

                        }
                    /*Display the cooridinates of pythagorean triples in the given range O to N*/
                    printf("\n\t%d.(%d, %d, %d)\n", i++, a, b, c);
                    }
            }
        }

        /*Print the coordinates of the triple with the largest c value*/
        printf("\n\tThe triple wth the largest value of c is (%d, %d, %d)\n", max_a, max_b, largest);

    }
    else

    {
        /*If there are no pythagorean triples in the range 0 to N, print that there are no pythagorean triples in the range 0 to N*/
    print("\n\tThere are no triples in this loop\n");
    }


}
