java program to find sum of series

import java.io.*;
import java.util.*;
class sum_series{
public static void main(String args[])
{
int num1,num2=0;
System.out.println(“nEnter the limitn”);
Scanner sc=new Scanner(System.in);
num1=sc.nextInt();
for(int i=0;i<=num1;i++)
{
num2=num2+i;
}
System.out.println(num2);
}
}

OUTPUT-
Enter the limit
5
15

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat