What is the least number that must be added to 299 to make the sum square 30 27 20 None?
View Discussion Show Improve Article Save Article View Discussion Improve Article Save Article Given a positive integers N, the task is to find the smallest number whose sum of digits is N.
Naive Approach:
Below is the implementation of the above approach. C++
Java
Python3
C#
Javascript
Time Complexity: O(N). Efficient Approach:
Below is the implementation of the above approach C++
Java
Python3
C#
Javascript
Time complexity: O(logN) since inbuilt pow function is being used What least number must be added to 299 to make the sum of perfect square?The factors of 299 are 13 and 23. To make it a perfect square, we have to pair both factors. So, to make 299 a perfect square we need to multiply it by 13 and 23.
Is 299 a square number?Is the number 299 a Perfect Square? The prime factorization of 299 = 131 × 231. Here, the prime factor 13 is not in the pair. Therefore, 299 is not a perfect square.
What is the least number to be added to 269 to make it a perfect square?Detailed Solution
The nearest perfect square of 269 is 289, i.e., the square of 17. Hence, the least number to be added to make 269 a perfect square is 20.
What is the smallest number to add 300 to perfect square?The closest square greater than 300 is 324. Hence 24 must be added to 300 to make it a perfect square.
|