Program to find the common ratio of three numbers | Python 3 implementation of above approach ; Function to print a : b : c ; To print the given proportion in simplest form . ; Driver code ; Get ratio a : b1 ; Get ratio b2 : c ; Find the ratio a : b : c
import math NEW_LINE def solveProportion ( a , b1 , b2 , c ) : NEW_LINE INDENT A = a * b2 NEW_LINE B = b1 * b2 NEW_LINE C = b1 * c NEW_LINE gcd1 = math . gcd ( math . gcd ( A , B ) , C ) NEW_LINE print ( str ( A // gcd1 ) + " : " + str ( B // gcd1 ) + " : " + str ( C // gcd1 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = 3 NEW_LINE b1 = 4 NEW_LINE b2 = 8 NEW_LINE c = 9 NEW_LINE solveProportion ( a , b1 , b2 , c ) NEW_LINE DEDENT