Computer Science, asked by Ashvi16, 1 year ago

WAP to find some of the attached series.....>>>>>>15 points

Attachments:

Answers

Answered by uneq95
1
1.

int n;
cin>> n;
double sum= 0;
double term ;
for(int i =1; i<=n;i++){
sum += ((i)+(i+1))/((i+1)*(i+2));
}
cout<< sum;

2.

int n;
cin>> n;
double sum= 0;
double term =1;
for(int i =1; i<=n;i++){
term = term /i;
sum += term;
}
cout<< sum;

That's it!
Include the header file iostream like the standard programs.

uneq95: but i would have to write everything again..
Ashvi16: ur wish.....i u don't want to
Ashvi16: then nvr mindvleave it
uneq95: no problem. i am not losing anything neither gaining something.
Ashvi16: so..??
Ashvi16: can u
uneq95: i can! but i am not gonna write it again
Ashvi16: no problem
Ashvi16: leave it
uneq95: as u wish
Answered by QGP
1
import java.util.*;
public class Series1
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        double i,n,sum=0,p;
        System.out.print("Enter the value of n: ");
        n = in.nextDouble();
        for (i=1;i<=n;i++)
        {
            p = (i+(i+1))/((i+1)*(i+2));
            sum = sum + p;
        }
        System.out.println();
        System.out.println("Sum of given series is: "+sum);
    }
}

_____________________________________________________________

import java.util.*;
public class Series2
{
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        double i,p=1,s=0,n;
        System.out.print("Enter the value of n: ");
        n = in.nextDouble();
        for (i=1;i<=n;i++)
        {
            p=p*i;
            s+=1/p;
        }
        System.out.println();
        System.out.println("Sum of series is: "+s);
    }
}            
Similar questions