get Sum Of The Square - CSharp System

CSharp examples for System:Math Number

Description

get Sum Of The Square

Demo Code


using System;/*from w w w. j  a  va  2 s . co  m*/

public class Main{
        public static long getSumOfTheSquare(int n) {
         double sum = 0;

         for (var i = n; i > 0; i--) {
            sum += Math.Pow(i, 2);
         }

         return (long) sum;
      }
}

Related Tutorials