00:00
00:00
View Profile BobicrafterDDT

Joined on 10/27/23

Level:
2
Exp Points:
42 / 50
Exp Rank:
> 100,000
Vote Power:
2.60 votes
Rank:
Civilian
Global Rank:
> 100,000
Blams:
0
Saves:
1
B/P Bonus:
0%
Whistle:
Normal
Medals:
11

BobicrafterDDT's News

Posted by BobicrafterDDT - October 30th, 2023


Now i`ve advanced the program and you can now Find the Biggest General Divisor with three numbers. The code is below if eanyone needs it.

/**
     * Find Biggest General Divisor
     * @param num1
     * @param num2
     * @param num3
     * @return 
     */
    public float FBGD(int num1, int num2, int num3) {
       ArrayList<Float> NG1 = new ArrayList<>();
       ArrayList<Float> NG2 = new ArrayList<>();
       ArrayList<Float> NG3 = new ArrayList<>();
       ArrayList<Float> Divisors = new ArrayList<>();
       for (int i = 1; i <= num1; i++) {
          float x = num1;
          x = x / i;
          if (x % 1 == 0) {
             NG1.add(x);
          }
       }
       for (int j = 1; j <= num2; j++) {
          float y = num2;
          y = y / j;
          if (y % 1 == 0) {
             NG2.add(y);
          }
       }
       for (int k = 1; k <= num3; k++) {
          float z = num3;
          z = z / k;
          if (z % 1 == 0) {
             NG3.add(z);
          }
       }
       for (int a = 0; a <= NG1.size() - 1; a++) {
          float curNum1 = NG1.get(a);
          for (int b = 0; b <= NG2.size() - 1; b++) {
             float curNum2 = NG2.get(b);
             for (int c = 0; c <= NG3.size() - 1; c++) {
                float curNum3 = NG3.get(c);
                if (curNum1 == curNum2 && curNum1 == curNum3 && curNum2 == curNum3) {
                   Divisors.add(curNum1);
                }
             }
          }
       }
       Divisors.sort(Comparator.naturalOrder());
       float numDiv = Divisors.size() - 1;
       float maxDiv = Divisors.get((int) numDiv);
       return maxDiv;
    }

Now, see, this is kind of the previous program that i made, but with some additions. To see the previous program click the link below.

LINK


Posted by BobicrafterDDT - October 30th, 2023


So, i`m now fifth grande and i am learning about Biggest General Divisor. And i really struggled to understand how to do it, but at the last moment i understood. And this idea poped into my head: "What if i just make a program on Java which finds me Biggest General Divisor?". So i got on my computer and started programming. After a few days i was ready an so did the program. But the problem was that it could calculate with only two numbers. Anyways, the code is below if anyone wants to use it...

    /**
     * Find Biggest General Divisor
     * @param num1
     * @param num2
     * @return 
     */
    public float FBGD(int num1, int num2) {
       ArrayList<Float> NG1 = new ArrayList<>();
       ArrayList<Float> NG2 = new ArrayList<>();
       ArrayList<Float> Divisors = new ArrayList<>();
       for (int i = 1; i <= num1; i++) {
          float x = num1;
          x = x / i;
          if (x % 1 == 0) {
             NG1.add(x);
          }
       }
       for (int j = 1; j <= num2; j++) {
          float y = num2;
          y = y / j;
          if (y % 1 == 0) {
             NG2.add(y);
          }
       }
       for (int a = 0; a <= NG1.size() - 1; a++) {
          float curNum1 = NG1.get(a);
          for (int b = 0; b <= NG2.size() - 1; b++) {
             float curNum2 = NG2.get(b);
             if (curNum1 == curNum2) {
               Divisors.add(curNum1);
             }
          }
       }
       Divisors.sort(Comparator.naturalOrder());
       float numDiv = Divisors.size() - 1;
       float maxDiv = Divisors.get((int) numDiv);
       return maxDiv;
    }