Find minimum positive value of a such that ( a * b ) % c = 0 here b and c are given .
For eg 1 : - ( a * 1 ) % 2 = 0 when a = 2
For eg 2 : - ( a * 2 ) % 7 = 0 when a = 7
For eg 3 : - ( a * 3 ) % 4 = 0 when a = 4
I have one solution in mind by iterating over all the divisor of c and thereby checking the condition to gets true .
Is there any other alternative and efficient solution for it ?
Take $a=c/\gcd(b,c)$ (with any greatest-common-divisor-computing algorithm you like).
The proof is easy. Let $d=\gcd(b,c)$; then $b/d$ and $c/d$ are coprime. So if $c$ divides $ab$, then $c/d$ divides $a(b/d)$, and therefore $c/d$ divides $a$, which makes the minimum $a$ equal $c/d$.
Yet another way to look at it is using factorizations: for a prime $p$, let $a_p$ (resp. $b_p$, $c_p$) be the greatest $k\geqslant 0$ such that $p^k$ divides $a$ (resp. $b$, $c$). Then we must have $a_p+b_p-c_p\geqslant 0$, and the smallest $a_p$ satisfying this is $\max\{0,c_p-b_p\}=c_p-\min\{b_p,c_p\}$, corresponding to $$a=\prod_p p^{a_p}=\prod_p p^{c_p}\Big/\prod_p p^{\min\{b_p,c_p\}}=c/\gcd(b,c).$$