To calculate the no of divisor how the sleve array be a part

sleve array which we created is a boolean array which contain only 0 or 1 values 0 for the even numbers and 1 for the prome numbers numbers
or first we have to calculate the sleve array of prime numbers to solve this problem
i am totally confuse in this concept .

Hey @anshulgurawalia


So just modify your sieve array accordingly. You will be able to find number of divisor for any number n.
Have mentioned the formula too.

is this code correct ?? using sieve or not

Approach is correct, but it’s not kade up by using sieve. It’s a naive approach and seems right.

can you please edit my code and make it sieve approach ??this thing i want to know how you are creating it as a sieve approach

This is the code by using sieve

Make sieve and after that
image
Find divisors with the power like we found 2^2 in number 60, store that in a container both prime factor with their frequency and then calculate number of divisors using the formula i have given.

please consider this code and tell the mistake i am not getting the correct answer

Check now ->

please comment out the

can you please comment out my mistakes

I did it in line number 41

p = primesleve[i+1]; is not same as p = primesleve[i++]; ??

Nope, for eg if i=2 then i+1 will be 3 but when you again do i+1 it will be 3 only. Whereas when you do i++ it will first 3 then 4 and so on…

okkkie… thankyou soooo…much

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.