You are given three non-zero numbers. Your task is to determine whether they form a geometric progression (GP), meaning the ratio between consecutive terms is constant.
Print Yes if the numbers form a geometric progression; otherwise, print No.
Input: a = 2, b = 4, c = 8
Output: Yes
Explanation: The common ratio is 2 throughout.
Input: a = 2, b = 6, c = 12
Output: No
Explanation: The ratios 3 and 2 are not equal.
Input: a = 3, b = 3, c = 3
Output: Yes
Explanation: A constant sequence has a common ratio of 1.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
2 4 8
Yes
3 6 12
Yes