Given a number N. The task is to express N as sum two Abundant Numbers. If it is not possibe print -1.
Input : N = 24 Output : 12, 12 Input : N = 5 Output : -1
Approach : An efficient approach is to store all abundant numbers in a set. And for a given number N run a loop from 1 to n and check if i and n-i are abundant numbers or not.
Below is the implementation of the above approach:
- Check if a number can be expressed as a sum of consecutive numbers
- Check whether a number can be expressed as a product of single digit numbers
- Check if a prime number can be expressed as sum of two Prime Numbers
- Check if a number can be expressed as 2^x + 2^y
- Check if a number can be expressed as a^b | Set 2
- Check if a number can be expressed as power | Set 2 (Using Log)
- Check if a number can be expressed as x^y (x raised to power y)
- Abundant Number
- N expressed as sum of 4 prime numbers
- Check if an integer can be expressed as a sum of two semi-primes
- Find ways an Integer can be expressed as sum of n-th power of unique natural numbers
- Number expressed as sum of five consecutive integers
- Check if a number can be written as a sum of 'k' prime numbers
- Check if given number can be represented as sum of two great numbers
- Check whether product of 'n' numbers is even or odd
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.