Sum of squares of first n natural numbers | C # Program to find sum of square of first n natural numbers ; Return the sum of square of first n natural numbers ; Iterate i from 1 and n finding square of i and add to sum . ; Driven Program
using System ; class GFG { static int squaresum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } public static void Main ( ) { int n = 4 ; Console . WriteLine ( squaresum ( n ) ) ; } }