Advertisement
Locoluis

Series

Jul 12th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. import java.io.*;
  2. public class series
  3. {
  4.  
  5.     public static void main(String args[])throws IOException
  6.     {
  7.         long n;
  8.         DataInputStream obj=new DataInputStream(System.in);
  9.         System.out.println("Enter n");
  10.         n=Integer.parseInt(obj.readLine());
  11.         double bigsum = 0.0;
  12.         for(long j = 1; j <= n; j++) {
  13.             long sum=1, product=1;
  14.             double computedterm;
  15.             for(long i=2; i <= (j + 1) ;i++)
  16.             {
  17.                 sum+=i;
  18.                 product*=i;
  19.             }
  20.             computedterm = sum * 1.0 / product;
  21.             bigsum += computedterm;
  22.         }
  23.         System.out.println( bigsum );
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement