Java probability if 2 integers are coprime Hi I am trying to write a programme that outputs the probability that the two randomly selected numbers are coprime

Two integers are coprime if the only positive integer that divides into both of them
is 1. In other words, the greatest common divisor of two coprime numbers is 1.
If two numbers x and y are selected randomly, the odds that they will be coprime
with each other is 61% (6 divided by PI^2). But what if we put some restrictions on
the two numbers? For example, if x is a randomly selected number that is divisible
by 7 and y is a randomly selected number that is divisible by 13? In this case, the
odds that they are coprime is 49%.
I am given a divisor of the first number and a divisor of the
second number. I must then output an integer from 0 to 100, which is the
percentage probability that the two randomly selected numbers are coprime.

here is what I have so far
import java.util.Scanner;
public class Main {
    public static int myTestMethod(int a, int b)
    //method taking two numbers a and b 
    {
        //Calculating gcd because if gcd is 1 then a and b are //coprimes. 
        if (b == 0)
            return a;
        else
            return myTestMethod(b, a % b);
    }
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.println(&quot;Enter a and b&quot;);
        int y;
        float p = 0;
        //taking inputs a and b two numbers. 
        int a = sc.nextInt();
        int b = sc.nextInt();
        //Calculating gcd by calling method
        y = (myTestMethod(a, b));
        System.out.print(&quot;gcd is:&quot;);
        System.out.println(y);
        p = (myTestMethod(a, b));
        //if gcd is 1 the probability should be 1 
        if (y == 1) {
            System.out.println(&quot;probability is:&quot;);
            System.out.println(p);
        }
        //else print probability as p/100.
        else {
            System.out.println(&quot;The probability is :&quot;);
            System.out.println(p / 100);
        }
    }
}

is this the correct way to go about it?
This review is for the code only, not the optimization / correctness; I assume the code works as IS.
Avoid using C-style array declaration
In the main method, you declared a C-style array declaration with the args variable.
before
String args[]

after
String[] args

In my opinion, this style is less used and can cause confusion.
Always add curly braces to loop &amp; if
In my opinion, it's a bad practice to have a block of code not surrounded by curly braces; I saw so many bugs in my career related to that, if you forget to add the braces when adding code, you break the logic / semantic of the code.
Before
if (b == 0)
   return a;
else
   return myTestMethod(b, a % b);

After
if (b == 0) {
   return a;
} else {
   return myTestMethod(b, a % b);
}

Other things
To save space in the main method, you can inline the variable y and p
//[...]
int y = (myTestMethod(a, b));
//[...]
float p = (myTestMethod(a, b));
//[...]

You can take less lines for the printing in the main method
You can make a printing method
public static void main(String[] args) {
   if (y == 1) {  //if gcd is 1 the probability should be 1
      printMultiLine(&quot;probability is:&quot;, p);
   } else { //else print probability as p/100.
      printMultiLine(&quot;The probability is :&quot;, p / 100);
   }
}

private static void printMultiLine(String message, float value) {
   System.out.println(message);
   System.out.println(value);
}

or
You can uses java.io.PrintStream#printf
java.io.PrintStream#printf offer you to use patterns to build the string without concatenating it manually. The only downside is you will be forced to add the break line character yourself; in java you can use the %n to break the line (portable between various platforms) or uses the traditional \n / \r\n.
public static void main(String[] args) {
   //[...]
   if (y == 1) {  //if gcd is 1 the probability should be 1
      System.out.printf(&quot;probability is:%n%f&quot;, p);
   } else { //else print probability as p/100.
      System.out.printf(&quot;The probability is:%n%f&quot;, p / 100);
   }
}