So I´ve been trying to solve this problem, but I just can´t. The thing is, I put a number of row in triangle, (can be any random number/row) and the program should return the sum of the squares of all the coefficients in that row.
#include <stdio.h>
unsigned long sum_triangle(const int row);
int main(){
printf("%lu\n", sum_triangle(7));
// sum(7)....7 is number of row
return 0;
}
unsigned long sum_triangle(const int row){
unsigned long sum = 0;
int temp =0;
for (int line = 0; line <= row ; line++) {
for (int number = 0; number <= line ; number++){
if (line == row){
temp = THIS NEEDS TO BE COMBINED SOMEHOW(line , number);
sum += (temp * temp);
}
}
}
return sum;
}
Problem is in the "temp". I need to somehow combine row and number and thats it. Any help would be much appreciated.