Wednesday, May 11, 2011

Sum , factorial

/*sum upto n numbers*/ 
public static int Sum(int n)
    {
      int result = 0;
      for (int i = 1; i <= n; ++i)
         result += i;
      return result;
    }

0 comments:

Post a Comment