Java Program to Find Ratio of the Distance between the Centers of the Circles and the Point of Intersection of Two Direct Common Tangents to the Circles

bookmark

import java.io.*;
class Main
{
    public static void main(String [] args)
    {
        double R1 = 20;
        double R2 =  10;   
        int gcd = 1; 
        for (int i = 1; i<=R1 && i<=R2; i++)
        {
            if(R1%i==0 && R2%i==0)
                gcd = i;
        }
        int res1 = (int)R1/gcd;
        int res2 = (int)R2/gcd;
        System.out.println("The ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles is " + res1+ " : " + res2);
    }
}
Output:

The ratio of the distance between the centers of the circles and the point of intersection of two

direct common tangents to the circles is 2 : 1