Java

Calculate Sum Of Numbers That Are Divisible By 8 Of First 100 Natural Numbers Using Java

Calculate Sum Of Numbers That Are Divisible By 8 Of First 100 Natural Numbers Using Java
// Sum of numbers that are divisible by 8 of first 100 natural nos 

class ssvsumnat1 
{ 
public static void main(String args[]) 
{ 
int sum = 0; 
System.out.println("\n\n\tSum of numbers that are divisible by 8 of first 100 natural nos"); 
System.out.print("\t******************************************************"); 
for(int i=1;i<=100;i++) 
{
if(i%8 == 0) 
sum = sum + i; 
}
System.out.println("\n\n\t\tSUM = " + sum); 
} 
}

Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.