Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Advanced_Loops - created by borkins on 2017-04-08.
- */
- import java.util.Scanner;
- public class _07_GreatestCommonDivisor
- {
- public static int gcd(int a, int b)
- {
- while (a != b)
- {
- if (a > b)
- a -= b;
- else
- b -= a;
- }
- return a;
- }
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int a = Integer.parseInt(console.nextLine());
- int b = Integer.parseInt(console.nextLine());
- System.out.println(gcd(a, b));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment