What is this line doing? csum[i] = csum[i-1]+p[i]

I Did not get the logic behind this line

Hey @JaveedYara it means that at ith index you are storing the value of number of primes till (I-1)th index and, +p[i] means That if p[i] is equal to 1 then that will increase the count csum[i] = csum[i-1] + 1 , or if it will be zero then csum[i] = csum[i-1]
Hope it will help you understanding this problem in a better approach :slight_smile:

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.