Date created: Sunday, July 10, 2011 7:19:32 PM. Last modified: Thursday, December 13, 2012 11:41:20 AM

Problem 9

// Project Euler - Problem 9
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char *argv[]) {

        int a, b, c;
        int top=500;

        for(a=1;a<=top;a++) {
                for(b=1;b<=top;b++) {
                        for(c=1;c<=top;c++) {
                                if (a<b) {
                                        if(b<c) {
                                                if((a*a)+(b*b)==(c*c)) {
                                                        if(a+b+c==1000) {
                                                                printf("a= %d b= %d c= %d; a*b*c= %d\n", a, b, c, (a*b*c));
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }
        return EXIT_SUCCESS;
}

Previous page: Problem 8
Next page: Problem 10