Count of distinct values till C formed by adding or subtracting A , B , or 0 any number of times | Function to calculate gcd ; Function to find number of possible final values ; Find the gcd of two numbers ; Calculate number of distinct values ; Return values ; Driver Code
def gcd ( A , B ) : NEW_LINE INDENT if ( B == 0 ) : NEW_LINE INDENT return A ; NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( B , A % B ) ; NEW_LINE DEDENT DEDENT def getDistinctValues ( A , B , C ) : NEW_LINE INDENT g = gcd ( A , B ) ; NEW_LINE num_values = C / g ; NEW_LINE return int ( num_values ) ; NEW_LINE DEDENT A = 2 ; NEW_LINE B = 3 ; NEW_LINE C = 10 ; NEW_LINE print ( getDistinctValues ( A , B , C ) ) ; NEW_LINE