galinyotsev123

ProgBasics05while-Loop-Y01greatestCommonDivisorCGD

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