I have tried this question, but I don’t know why I am getting run time error.

This is my source code: https://www.codechef.com/viewsolution/18906609

I am a beginner and I am stuck. Please help me correct this code. I am really thankful to you.

### I think your logic is wrong… after checking

if((value%j)==0)

#you need to check if “j” is prime or not…

IDK what your algo does…

Do count++ if j is prime

else do nothing

And after inner loop gets over do sum+=count as you did…

Check codes for checking if a number is prime or not…

yah! it worked, but unfortunately with the wrong O/P.

i replaced i with value inside the while loop, but its giving worng o/p. pls suggest correction. below is code in which i have replaced i with value. see while loop…

for(i=n;i<m;i++)

{

value=i

for(j=2;j<=sqrt(value);j++)

{

if((value%j)==0)

{

count=0;

while((value%j)==0)

{

count++;

value=value/j;

if(value==j)

{ count–;

}

}

sum+=count;

}

}

if(i!=1)

{

sum+=1;

}

}

### In case you need to refer an optimised logic which is O(1) for each test case for this question and runs in 0.01 sec is HERE

code is neat and you can always feel free to ask queries… and also ask if you need explanation on my solution…