Below is what I need to calculate efficiently.
- Find the number of natural numbers which is divisor of both $N$ and $K$.
- Find the number of natural numbers which is divisor of $N$ and is divisible by $K$.
- Find the number of natural numbers which is divisor of N and is not divisible by K.
$1\leq N\leq 10^{12} \\ 1\leq K \leq 10^{12}$
$N$ would be constant for all the above queries whereas $K$ would change in the question. I know for first one I can calculate the GCD of $N$ and $K$ and then divide it by smaller of $N$ and $K$. But I have no clue about other 2 queries. please help me crack this.