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; } }