Changes in code coz tle

I changed your code https://ide.codingblocks.com/s/264517, now it doesn’t give TLE, but it shows wrong answer in 2 testcases.
This is because you need to calculate the sum of digits of all prime factor.But you are simply adding the prime factor.
For example if number is 23, your code gives 0 as answer but it should be 1.
Because sum of digits of given number is 2+3 = 5.
Now it has only 1 prime factor ,i.e., 23 .
Now you are comparing 23 with 5, instead you need to 2+3(sum of digits of prime factors) and the compare it to 5.
So make the necessary changes in your code.
This is what your code should do

Generate All prime Factors of the number.
Write a Function that calculates the sum of digits of 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 given number.
 If yes print 1.
otherwise print 0.
1 Like

tried with 3rd loop but tle

See this implementation please https://ide.codingblocks.com/s/264530

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.