gulzaar

HCF

Feb 21st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * @author Ravinesh
  5.  *
  6.  */
  7. public class que3_hcf {
  8.  
  9.     /**
  10.      * @param args
  11.      *
  12.      */
  13.     public static int elucid(int x, int y) {
  14.            
  15.          while (y != 0) {
  16.               int r = x % y;
  17.               x = y;
  18.               y = r;
  19.               }
  20.              return x;
  21.     }
  22.    
  23.    
  24.     public static void main(String[] args) {
  25.         // TODO Auto-generated method stub
  26.        
  27.         int m,n;
  28.        
  29.         Scanner in = new Scanner(System.in);
  30.        
  31.         System.out.println("Computing the HCF \nEnter the Value of first no : ");
  32.         m = in.nextInt();
  33.        
  34.         System.out.println("Enter the Value of second no : ");
  35.         n = in.nextInt();
  36.        
  37.         System.out.println("the HCF betwwen " + m + " & "+ n + "  is : " + elucid(m, n));
  38.        
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment