Find The Number N, Where (N+X) Divisible By Y And (N-Y) Divisible By XIn this tutorial, we will learn how to determine the number N, where (N + X) divisible by Y and (N-Y) divisible by X. This is Two numbers, X and Y, are given. Finding the number N(N ≤ 10^18) that meets these two requirements: (N + X) can be divided by Y, and (N - Y) can be divided by X. Examples: The following concept can be used to solve the problem. The number system is a straightforward mathematical idea that we can use. Normalizing the equation allows us to obtain N could be the same as (X*Y - X + Y). Additionally, it meets these two requirements. The solution is therefore (X * Y - X + Y). The application of the aforementioned strategy is seen below: C++ Program 1: Output 780 C++ Program 2: Output 384 Java Code 1: Output 780 Java Code 2: Output 384 C# Code 1: Output 780 C# Code 2: Output 384
So that's the end of the article. I sincerely hope you find this post to be educational and useful. |
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week