24 lines
531 B
C
24 lines
531 B
C
unsigned long some_heavy_stuff(int lima, int limb) {
|
|
unsigned long result = 0;
|
|
int i, j = 0;
|
|
int sum = 0;
|
|
for (i = 0; i < lima; i++) {
|
|
sum = 0;
|
|
for (j = 0; j < limb; j++) {
|
|
sum += i + j;
|
|
}
|
|
result += sum;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
unsigned long lesser_heavy_stuff(int lima, int limb) {
|
|
unsigned long result = 0;
|
|
int i, j = 0;
|
|
for (i = 0; i < lima; i++) {
|
|
// Optimize sum of first n numbers
|
|
// Factorize outer index
|
|
result += (i * limb) + ((limb - 1) * limb) / 2;
|
|
}
|
|
return result;
|
|
}
|