To print the sum of first 20 natural numbers

18/03/2013 08:26

 

public class adding20naturalnumbers
{
public static void main(String args[])
{
int sum=0;
for(int i=1;i<=20;i++)
{
sum=sum+i;
System.out.println(sum);
}
}
}