Practice Question 2

Home / Java Practice Question / Practice Question 2

Practice Question 2


Question 2. Given a single integer N, your task is to find the sum of the square of the first N even natural Numbers.

                         Example 1: 

                         Input: 3

                         Output: 56

                         Explanation: 22 + 42 + 62 = 56

Program


class Solution

{

    public long sum_of_square_evenNumbers(long n)

    {

            long sq = 0;

        long num = 2;

        for (int i=0; i<n; i++){

            sq += (num*num);

            num += 2;

        }

        return sq;

    }

}