Timer is Running

Largest Proper fraction
Submissions: 358   Accuracy:


  Difficulty: Easy   Marks: 2

Given a number N. Find the values of a and b such that a/b is the largest proper fraction and a + b = N. Following are constraints for fraction.
1.a/b is a proper fraction if a is less than b and a and b are co-primes i.e no common factor of a and b.
2.There can be multiple proper fractions with sum of numerator and denominator equal to a given number. The main task is to find values of a and b for which the fraction is having the maximum floating point value.

The first line consists of an integer T i.e number of test cases. The first and only line of each test case consists of an integer N

Print the values of a and b with spaces in between.

1 <= T <= 100
3 <= n <= 105


1 2
5 7

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre
Author: saksham0751

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.