Here you can find the source of sumOfSquares(int numberOfTerms)
public static int sumOfSquares(int numberOfTerms)
//package com.java2s; //License from project: Open Source License public class Main { public static int sumOfSquares(int numberOfTerms) { return (int) (((double) numberOfTerms / 6) * (numberOfTerms + 1) * (2 * numberOfTerms + 1)); }// w w w .j a va 2s . co m }