Official algorithmic problem description and constraints.
You are given an integer π₯. Your task is to find any integer π¦ (1β€π¦<π₯) such that gcd(π₯,π¦)+π¦ is maximum possible.
Note that if there is more than one π¦ which satisfies the statement, you are allowed to find any.
gcd(π,π) is the Greatest Common Divisor of π and π. For example, gcd(6,4)=2.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.