The moving module operator on the other side of the equation

I have a math problem that is part of my programming problem

I have an operator like

a = b%30;

How can I calculate bin terms a?

I thought, but could not understand.

+4
source share
2 answers

A-priory

b == 30*n + a

for some whole n.

Note that there are several values bthat can give you the same a:

>>> b = 31
>>> b % 30
1
>>> b = 61
>>> b % 30
1
+5
source

Firstly, it’s obvious that for a given awhole there are several solutions for b.

% - , , a . , - , ?

| a | >= 30,

a = 0, 30.

0 < a < 30, b , b = 30 * k + a k.

-30 < a < 0, - b , b = - (30 * k - a) k.

+1

All Articles