Date created: 07/10/11 19:12:02. Last modified: 12/13/12 11:41:20

Problem 6

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

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

        int count = 0;
        int squares = 0;
        int total = 0;

        while (count<=atoi(argv[1])) {
                squares += count * count;
                total += count;
                count++;
        }

        printf("Difference: %d\n", (total*total)-squares);
        return EXIT_SUCCESS;
}

Previous page: Problem 5
Next page: Problem 7