the 12th question in ProjectEuler.net is about triangle numbers…
I must found the first triangle which have 500 factors…
My thought is so poor, and I code very dirty: I just, keep dividing the numbers below the triangle numbers one by one… can anyone have any other ideas?
Though my code is not complete yet, I post it below:
#include
int trinum(int topMax){
int i, result;
result = 0;
for(i = 1; i <= topMax; i++){
result += i;
printf("%-3d:", result);
factor(result);
}
return 1;
}
int factor(number){
int j = 1;
for(; j<= number; j++){
if(number % j == 0){
printf("%d,", number / j);
}
}
printf("\n");
}
int
main()
{
int top;
printf("Input your top:\n");
scanf("%d", &top);
printf("================================\n");
trinum(top);
printf("\n");
return 0;
}