codewars032: Financing Plan on Planet XY140Z-n

Sourcejava

package codewars;
import java.math.BigInteger;
public class Finance{
    public static BigInteger finance(int n){
        BigInteger sum = new BigInteger("0");
        int head = 0;
        for(int i = 0; i <= n; i++){
            for(int j = head; j <= head + n - i; j++){
                sum = sum.add(new BigInteger(String.valueOf(j)));
            }  
            head += 2;  
        }    
        return sum;
    }       
}
相關文章
相關標籤/搜索