Bug: An elusive creature living in a program that makes it incorrect. The activity of "debugging", or removing bugs from a program, ends when people get tired of doing it, not when the bugs are removed.
Program to find the sum of the series, 3+5+9+15+……..
import java.io.*;
class test
{
public static void main(String[] asd)throws IOException
{
BufferedReader obj= new BufferedReader(new InputStreamReader(System.in));
String num;
int n,sum=3, result=0;
System.out.print("Enter the value till you want the sum of the series.");
num=obj.readLine();
n=Integer.parseInt(num);
System.out.println("SERIES IS::");
System.out.print("3 ");
for(int i=0;i<n;i++)
{
sum=sum+ (2*(i+1));
result+=sum;
System.out.print(sum+" ");
}
System.out.println("Sum of the series:: "+(result+3)+".");
}
}
I'm working as Project Lead in Oracle. I'm mainly into Microsoft technologies but quite interested in Java and C. I'm not a professional blogger, whatever I find interesting I read it and write a blog post just to share my understanding.
View all posts by Sunil Kumar