Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lista.Alapok;
- public class Main {
- public static int getGreatestCommonDivisor(int first, int second) {
- if(first<10 || second<10) return -1;
- int count=0;
- for (int i = 1; i <=first && i<=second ; i++) {
- if (first%i==0 && second%i==0)
- count=i;
- } return count;
- }
- public static void main(String[] args) {
- System.out.println(getGreatestCommonDivisor(12, 30));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement