Your approach is wrong. The greatest common divisor of 30 and 40 is not your smallest n
.
You are looking for the smallest integer n > 0
that satisfies 40*n = 0 (mod 30)
and 30*n = 0 (mod 40)
.
For the first equation, the result is n_1 = 3
. For the second equation, we get n_2 = 4
. The smallest n
to satisfy both equations is the least common multiple of n_1
and n_2
-- in this case, n = 12
.