one-file-projects/euler1.c
2015-11-22 18:19:34 +01:00

13 lines
243 B
C

#include <stdio.h>
int numbersum(int i, int p) {
int n = p/i;
return i*n*(n+1)/2;
}
int main( int argc, char *argv[] ) {
int n = 999;
int s = numbersum(3,n) + numbersum(5,n) - numbersum(15,n);
printf("%d\n",s);
return 0;
}