Given an integer N, the task is to find two numbers a and b such that a * b = N and a + b = N. Print “NO” if no such numbers are possible.
Input: N = 69
Output: a = 67.9851
b = 1.01493
Input: N = 1
Approach: If observed carefully, we are given with sum and product of roots of a quadratic equation.
If N2 – 4*N < 0 then only imaginary roots are possible for the equation, hence “NO” will be the answer. Else a and b will be:
a = ( N + sqrt( N2 – 4*N ) ) / 2
b = ( N – sqrt( N2 – 4*N ) ) / 2
Below is the implementation of the above approach:
a = 67.9851 b = 1.01493
- Find the Product of first N Prime Numbers
- Find if n can be written as product of k numbers
- Find two distinct prime numbers with given product
- Find maximum product of digits among numbers less than or equal to N
- Numbers less than N which are product of exactly two distinct prime numbers
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Check whether product of 'n' numbers is even or odd
- Product of 2 Numbers using Recursion
- Sort the numbers according to their product of digits
- Print a pair of numbers with the given Sum and Product
- Number of digits in the product of two numbers
- First digit in product of an array of numbers
- Product of all the Composite Numbers in an array
- Cumulative product of digits of all numbers in the given range
- Check if product of first N natural numbers is divisible by their sum
- Counting numbers whose difference from reverse is a product of k
- Last digit of Product of two Large or Small numbers (a * b)
- Sum and Product of all Composite numbers which are divisible by k in an array
- Product of all Subsets of a set formed by first N natural numbers
- Check if N can be expressed as product of 3 distinct numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.