Computer Science, asked by priyasenthil2414, 1 year ago

Write a program to find the some of the following series
S= 0,1,2,3,6...... n


neelbhatkar3: IN JAVA?

Answers

Answered by neelbhatkar3
2

import java.util.*;

public class sum

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int n,s=0,i;

System.out.println("enter the  last number in the series which has to be added");

n=sc.nextInt();

for(i=0;i<=n;i++)

{

s=s+i;

}

System.out.println("the sum of the  series is:"+s);

}

}

Similar questions