galinyotsev123

ProgBasicsJavaBook7.1ComplexLoop07greatestCommonDivisorCGD

Jan 14th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E07greatestCommonDivisorCGD {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int a = Integer.parseInt(scanner.nextLine());
  8. int b = Integer.parseInt(scanner.nextLine());
  9.  
  10. while (b != 0) {
  11. int oldB = b;
  12. b = a % b;
  13. a = oldB;
  14. }
  15. System.out.println("GGD = " + a);
  16.  
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment