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 limit\n");
Scanner sc=new Scanner(System.in);
num1=sc.nextInt();
for(int i=0;i<=num1;i++)
{
num2=num2+i;
}
System.out.println(num2);
}
}
import java.util.*;
class sum_series{
public static void main(String args[])
{
int num1,num2=0;
System.out.println("\nEnter the limit\n");
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
Comments
Post a Comment