I could not find out the error. Also, doubt in logic. https://ide.codingblocks.com/s/261128
Trie my best please help me.
I could not find out the error. Also, doubt in logic. https://ide.codingblocks.com/s/261128
Trie my best please help me.
Hello @ayusdas2000 , actually you don’t need to compute the prime no. you just need to create an expression and then use it as the formula.
What we actually need to do first of all calculate the total no. of divisors of the no.
And then calculate at how many places a particular prime is contributing.
Pls refer this and ask if you face any problem.
Could not find what ur a asking me to refer. Did u share any link?
Yes I shared a link of coding blocks ide.
could not understand the equation. ans = (ans * (1 + ((sum(v[i]) * ((pro * power(v[i] + 1, mod - 2)) % mod)) % mod))) % mod;. Also please tell why mod-2 and not mod
Hello do you know about modulo inverse ?? Here I need to take the mod while dividing and for that we need to implement modulo inverse. And here 10^9+7 is prime no. and for prime nos. we can find out the modulo using fermat’s theorem and it says if there is a no. let’s n and a prime no. p then,
(n^(p-1))%p == 1 considering n is not divisible by p.
And if I need to calculate (1/n)%p == (n^(p-2))%p and
that’s why I am using mod-2 as a power if mod is my prime no.
thank you understood why mod-2. But please explain the expression. ans = (ans * (1 + ((sum(v[i]) * ((pro * power(v[i] + 1, mod - 2)) % mod)) % mod))) % mod;
Pls try to dry run how the powers are getting multiplied with each other.
Suppose we get the total divisors for the no. if we multiply (1+a1)(1+a2)(1+a3)…(1+an)
And now in this if we see we are having 0,1,2,3,…a1 powers of two and everyone is getting multiplied with all the other powers. So for this 0,1,2,3,… a1 = > sum(a1) or sum(v[i]) we can do
And the remaining expression is giving ((1+a1)(1+a2)(1+a3)…(1+an))/(1+ai) for every i
Please tell me what the basic logic. I know to code it myself
Hello bro, the base logic is that first of all we must know how to find the divisors of a no.
And now see every particular value of a divisor is getting multiplied with other divisors. So if we know see it in terms of the powers of the primes we will see that we need to multiply every power of a no. with all the powers of the other nos.
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.