1^2+3^2+5^2+……+ n ^2.公式的计算的问题怎么采用C语言程序代码编写的过程技术的实现的方式

Problem Description
You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.

Input
In each case, there is an odd positive integer n.

Output
Print the sum. Make sure the sum will not exceed 2^31-1

Sample Input
3

Sample Output
10

long calc(int n){
    int i = 1;
    long result = 0 ;
    for(int i = 1;i<n;i = i+2){
        result += i*i;
    }
    return result;
}