Thursday, June 6, 2013

[Project Euler] Problem 1 in C

Problem: Project Euler Problem 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int total = 0, i;
    for (i = 1; i < 1000; i++){
        if (!(i % 5))
            total += i;
        else if (!(i % 3))
            total += i;
    }

    printf("%d\n", total);
    return 0;
}

Answer:

No comments:

Post a Comment