Advertisement

inverse modulus operator

Started by April 21, 2020 04:37 PM
14 comments, last by pbivens67 4 years, 4 months ago

I am converting four digits using the modulus operator. what I want to do is to convert them back to their original values.

	num_one = (digit_one + 7) % 10;
	num_two = (digit_two + 7) % 10;
	num_three = (digit_three + 7) % 10;
	num_four = (digit_four + 7) % 10;

Someone with a math background will tell you that there's an infinite number of answers. I could be wrong, but just see… https://www.wolframalpha.com/input/?i=solve+for+d+where+n+%3D+%28d+%2B+7%29+mod+10

Advertisement

well I go this problem out of one of my books so there is a definitive answer

The answer is 42.

nice reply but should I post in the math section?

pbivens67 said:
should I post in the math section?

No, you should not post this at all. ; )

17 % 10 = 7

27 % 10 = 7

37 % 10 = 7

With infinite inputs giving the same result, it's impossible to get a certain single input only from the result.

Either your book fools you or you hide something important from us.

Advertisement

ok sorry for asking

Are you an aspiring cryptographer?

no but this a cryptographic question.

https://stackoverflow.com/questions/61349597/converting-a-modulus-value-to-a-different-value-and-back-to-its-original-value

Why are some recent trolling questions also asked on stackoverflow?

This topic is closed to new replies.

Advertisement