Modular arithmetic using fractions
8
8 is the correct answer indeed.
7*4/11 mod 10
means we're looking at 7*4*x mod 10
where x is the modular inverse of 11 modulo 10, which means that 11*x mod 10 = 1
.
This is true for x=1
(11*1 mod 10 = 1
)
So 7*4*x mod 10
becomes 7*4*1 mod 10
which is 28 mod 10 = 8
Have a look here: "Is it possible to do modulo of a fraction" on math.stackexchange.com.
One natural way to define the modular function is
a (mod b) = a − b ⌊a / b⌋
where ⌊⋅⌋ denotes the floor function. This is the approach used in the influential book Concrete Mathematics by Graham, Knuth, Patashnik.
This will give you 1/2(mod3)=1/2.
To work through your problem, you have a = 7 * (4/11) = 28/11
, and b = 10
.
a / b
= (28/11)/10 = 0.25454545...
⌊a/b⌋
= 0
b ⌊a/b⌋
= 0 * 0 = 0
a - b ⌊a/b⌋
= 28/11 - 0 = 28/11
This means your answer is 28/11.
Wolfram Alpha agrees with me and gives 28/11
as the exact result. Google also agrees, but gives it as a decimal, 2.54545454.....
A fraction is an exact answer and not a decimal.