using System;
using System.Collections;
using System.Collections.Generic;
class MainClass {
static void Main() {
Console.WriteLine("Hello World!");
Console.WriteLine(Sum(100).ToString());
Console.WriteLine(Sum2(100).ToString());
Console.WriteLine(Sum3(100).ToString());
}
private static int Sum(int n)
{
ArrayList arrayList = new ArrayList();
for (int i = 0; i < n; i++)
{
arrayList.Add(i+1);
}
int s = 0;
for (int i = 0; i < arrayList.Count; i++)
{
s += (int)arrayList[i];
}
return s;
}
private static int Sum2(int n)
{
List<int> arrayList = new List<int>();
for (int i = 0; i < n; i++)
{
arrayList.Add(i + 1);
}
int s = 0;
for (int i = 0; i < arrayList.Count; i++)
{
s += (int)arrayList[i];
}
return s;
}
private static int Sum3(int n)
{
List<int> arrayList = new List<int>();
for (int i = 0; i < n; i++)
{
arrayList.Add(i + 1);
}
int s = 0;
foreach(int value in arrayList)
s += value;
return s;
}
}