A simple for loop would do it:
int compute(int n) {
int i, sum=0;
for(i=1; i<=n; i++) {
int val = i*(i+1)*(i+1);
sum += val;
}
return sum;
}
More Related Contents:
- Bit manipulation, return 0 if x != 0, or nonzero otherwise
- Cascaded and nested if statements in C programming language
- Finding length of array inside a function [duplicate]
- How do you pass a function as a parameter in C?
- What are the applications of the ## preprocessor operator and gotchas to consider?
- What is Bit Masking?
- Error handling in C code
- Should I explicitly cast malloc()’s return value? [duplicate]
- Unique random number generation in an integer array [duplicate]
- How to know what the ‘errno’ means?
- Reflection support in C
- What’s the best way to return a random line in a text file using C?
- What is the result of NULL + int?
- Floating point comparison `a != 0.7` [duplicate]
- Is Fortran easier to optimize than C for heavy calculations?
- gdb – debugging with pipe
- Are there any downsides to passing structs by value in C, rather than passing a pointer?
- What is the purpose of the unary plus (+) operator in C?
- Directly Read/Write Handshake data with Memory BIO
- Yet Another MinGW “gcc: error: CreateProcess: No such file or directory”
- Trying to generate 9 digit numbers with each unique digits
- Why does printf print random value with float and integer format specifier
- Pointer arithmetic when void has unknown size [closed]
- How do you write a C program to execute another program?
- Difference between char a[]=”string”; char *p=”string”; [duplicate]
- How to migrate this Make and Autotools project with multiple source subdirectories to CMake?
- Get index of substring
- implicit declaration of function usleep
- Any benefit in using WEXITSTATUS macro in C over division by 256 on exit() status?
- Declaring an array of negative length