I think I have used almost a brute force approach…please tell me about the efficient algo…
Please look at my algo and do check is there more efficient algo
Algorithm ->
Generate all prime Factors of the number.
Write a function that calculates the sum of digits of a passed number.
Pass each generated Prime Factor to this digits sum function till you can generate prime factors.
At last, equate your sum with the sum of digits of the given number.
4.1 If yes print 1.
4.2 otherwise print 0.
Note -> Make your code a little Efficient otherwise you will get TLE with brute force approach. By making code efficient is either you need to make your prime factor generator efficient or prime checker efficient in order to pass the test cases.
I got complete score with my algo
But I am thinking that there might be some changes…which could make it more efficient
I am just saying to analyse my code…and check if there is some efficiency THT I COULD ADD…
How can i know what you have coded.
Please send your code link.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.