Advertisement
tchenkov

L07u07_GreatestCommonDivisor

Feb 21st, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 20.02.2017 г..
  7.  */
  8. public class u07_GreatestCommonDivisor {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int numA = Integer.parseInt(scan.nextLine());
  12.         int numB = Integer.parseInt(scan.nextLine());
  13.        
  14.         while (numB != 0){
  15.             int numC = numB;
  16.             numB = numA % numB;
  17.             numA = numC;
  18.         }
  19.    
  20.         System.out.println(numA);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement