Find N Geometric Means between A and B | Python3 program to find n geometric means between A and B ; Prints N geometric means between A and B . ; calculate common ratio ( R ) ; for finding N the Geometric mean between A and B ; Driver Code
import math NEW_LINE def printGMeans ( A , B , N ) : NEW_LINE INDENT R = ( math . pow ( ( B / A ) , 1.0 / ( N + 1 ) ) ) ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( int ( A * math . pow ( R , i ) ) , end = " ▁ " ) ; NEW_LINE DEDENT DEDENT A = 3 ; NEW_LINE B = 81 ; NEW_LINE N = 2 ; NEW_LINE printGMeans ( A , B , N ) ; NEW_LINE