TheAlgorithms-C/project_euler/problem_6/sol.c

20 lines
329 B
C
Raw Normal View History

2020-06-06 00:20:25 +08:00
/**
* \file
* \brief [Problem 6](https://projecteuler.net/problem=6) solution
*/
2019-10-01 22:21:55 +08:00
#include <stdio.h>
2020-06-06 00:20:25 +08:00
/** Main function */
int main(void)
{
2019-10-01 22:21:55 +08:00
unsigned s1 = 0, s2 = 0, i;
for (i = 1; i <= 100; i++)
{
2019-10-01 22:21:55 +08:00
s1 += i * i;
s2 += i;
}
unsigned ans = s2 * s2 - s1;
printf("%u\n", ans);
return 0;
}