SHARE
TWEET

loop

a guest Nov 15th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class  exer{
  3.     public static void main (String[] args) {
  4.     Scanner scan= new Scanner(System.in);
  5.     System.out.println ("Enter limit number");
  6.     int N= scan.nextInt();
  7.     double one= 1.0;
  8.     int denom= 1;
  9.     double sum=0;
  10.     while(denom<=N){
  11.         sum= one/denom;
  12.         denom=denom++;
  13.     }
  14.     System.out.println ("Sum is: "+ sum);
  15. }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top