1. 
import java.io.*;
class series1
{
    public static void main()
    {
       double num=0.5;
System.out.print(num);
       for(int i=0;i<7;i++)
       {
num+=5*Math.pow(10,i);
System.out.print(", "+num);
        }
    }
}
o/p
0.5, 5.5, 55.5, 555.5, 5555.5, 55555.5, 555555.5, 5555555.5
2. Find the sum of the following series. 
2-4+6-8+..........n

import java.io.*;
class series2
{
    public static void main()throws IOException
    {
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number of ur choice");
int n=Integer.parseInt(br.readLine());
int count=1;
int sum=0;
        for(int i=1;i<=n;i+=2)
        {
            if(count%2!=0)
            {
                sum+=i;
            }
            else
            {
                sum-=i;
            }
            count++;
System.out.println(sum);
        }
    }
}

3. Find the sum of the series

1!+2!+3!+……….+n!

import java . io.*;

public class series3
{
    
public static void main() throws IOException 
{
       BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
       
System.out.println("Enter a Number");
 
      int n = Integer.parseInt (br.readLine());
   
    int sum=0;
       
for(int i=1;i<=n;i++)       
{
           
int fact =1;
           
for(int j=1;j<=i;j++)          
{
              
fact*=j;
        
}        
sum+=fact;   
} 
System.out.println(sum);
}
}   
   

LEAVE A REPLY

Please enter your comment!
Please enter your name here