get Square Of The Sum - CSharp System

CSharp examples for System:Math Number

Description

get Square Of The Sum

Demo Code


using System;//from www .j  av a2 s  . c  o m

public class Main{
        public static long getSquareOfTheSum(int n) {
         var sum = 0;

         for (var i = n; i > 0; i--) {
            sum += i;
         }

         return (long) Math.Pow(sum, 2);
      }
}

Related Tutorials