problem12
地址:https://projecteuler.net/problem=12。
源码:git@code.aliyun.com:c-program/projecteuler.git。
问题:1 + 2 + 3 + ...的和中第一个有超过500个因数。
#include <stdio.h>#include <math.h>#include "debug.h"#define NUM 500int main(int argc, char **argv){ int i = 0; int sum = 0; int num = 0; int j; debugTime(); while (num <= NUM){ i++; sum = i * (i + 1) / 2; num = 0; j = 1; while (j <= (sum / j)){ if (0 == (sum % j)){ if (j == (sum / j)) num++; else num += 2; } j++; } } printf("Problem12 Answer: %d\n", sum ); debugTime(); return 0;}