Skip to content

luc038.c

Problem Statement

Write a program to generate all Pythagorean Triplets with slide length less than or equal to 30.

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, c;
    printf("Pythagorean Triplets with slide length less than or equal to 30 : \n");
    for (a = 1; a <= 30; a++)
    {
        for (b = a; b <= 30; b++)
        {
            int c_square = a * a + b * b;
            for (c = b + 1; c <= 30; c++)
            {
                if (c * c == c_square)
                    printf("(%d, %d, %d)\n", a, b, c);
            }
        }
    }
    return 0;
}