To avoid making a mistake, you need to understand that the division by 97 is a Euclidean division, hence the presence of modulo in your title, I imagine you had grasped that...
Manu
Hello,
To avoid precision problems (you still need to calculate with 8 digits):
take the first 6 digits, multiply by 76 and add the last 7 digits: 249117*76+5118195 = 24051087 divide by 97 24051087/97 = 247949.350515 take the integer part, multiply by 97 and subtract it from the initial number 24051087-247949*97 = 34
The requested key is the complement to 97, which is 97-34 = 63
Manu
goldy91
Author
I just want to know where he found the number 76?
plustk
@goldy91The modulo of any number rounded to a power of 10 (be it 1000, 100000, or, as here, 10,000,000) is relatively easy to calculate. Thus, any number added to this rounding must incorporate this modulo, and any multiple of this number will have a modulo multiplied in the same way.
For example: 1000 % 97 = 30 (1000 / 97 = 10.309278 then 0.309278 * 97 = 30) Therefore, 10,000 % 97 must be 10x 30 (which still needs to be taken % 97, etc.). And thus 10,001 % 97 must be (10x 30 +1) % 97. So, by limiting the input to 4 or 5 digits, any number "aaa.bbb" modulo 97 equals (aaa x 30 + bbb) modulo 97
Since a standard calculator only has 8 digits, we first do 10,000,000 / 97 = 103092.78 then 0.78 x 97 = 76. So any number "a.aaa.aab.bbb.bbb" modulo 97 will yield the same result as ("aaaaaaa" x 76 + "bbbbbbb") modulo 97.
And for more than 13 digits, we can continue: a.aaa.aab.bbb.bbc.ccc.ccc % 97 => ??? First, 10,000,000,000,000 % 97 = (1,000,000 x 76 + 0) % 97 = 15 So this gives (aaaaaa x 15 + bbbbbbccccccc) % 97. The calculation aaaaaa x 15 + bbbbbbccccccc will necessarily yield a result with 13 digits (or 14 if bbbbbb = 999999, but the rest remains manageable for an 8-digit calculator), and then we redo it with 76 as above. So yes, we would need to break the calculation into two parts to do aaaaaa x 15 + bbbbbbccccccc (or do the addition on paper...), but it remains relatively simple to carry out. And we can continue this indefinitely - as long as we have the time to do it - by adding the same steps one after another.
plustk
@plustkOr, another way to look at the same question:
from which it is clear that: if (x % y) = z then (10x % y) = (10z % y) or more generally: (nx % y) = (n(x % y) % y) = (nz % y)
Since ((x+p) % y) = (((x % y) + p) % y) (for the modulo "y" of two added digits, one or both can be replaced by their modulo "y" without changing the result) therefore ((nx + p) % y) = ((n(x % y) + p) % y) and again, if (x % y) = z, ((nx+p) % y) = (nz + p) % y
Thus for any very large multiple n of x (in this case, the 6 largest digits of a 13-digit number, which are thus a multiple "n" of "x" where x = 10,000,000), if we know the result "z" of x % y (in this case, 76 if y = 97), the equation for a digit "a.aaa.aab.bbb.bbb" % 97 simply becomes (n * 76 + p) % 97 = ("aaaaaa" * 76 + bbbbbbb) % 97
And finally, for a 31-digit number "a.aaa.aab.bbb.bbc.ccc.ccd.ddd.dde.eee.eee" % y ... = ("aaaaaa" * (10^25 % y) + bbbbbbccccccddddddeeeeeee) % y = ("aaaaaa" * (10^25 % y) + ("bbbbbb" * (10^19 % y) + ccccccddddddeeeeeee) % y) % y and so on, which ultimately leads to: = ("aaaaaa" * (10^25 % y) + ("bbbbbb" * (10^19 % y) + ("cccccc" * (10^13 % y) + ("dddddd" * (10^7 % y) + "eeeeeee")))) % y
For modulo 97, we know 10^7 % 97 = 76, thus "a.aaa.aab.bbb.bbc.ccc.ccd.ddd.dde.eee.eee" % 97 = ("aaaaaa" * (10^18 * 76 % 97) + ("bbbbbb" * (10^12 * 76 % 97) + ("cccccc" * (10^6 * 76 % 97) + ("dddddd" * 76 + "eeeeeee")))) % 97 It is easy to calculate 10^6 * 76 % 97 = 15 = ("aaaaaa" * (10^12 * 15 % 97) + "bbbbbb" * (10^6 * 15 % 97) + "cccccc" * 15 + "dddddd" * 76 + "eeeeeee") % 97 Again, 10^6 * 15 % 97 = 17 = ("aaaaaa" * (10^6 * 17 % 97) + "bbbbbb" * 17 + "cccccc" * 15 + "dddddd" * 76 + "eeeeeee") % 97 And finally, 10^6 * 17 % 97 = 71 = ("aaaaaa" * 71 + "bbbbbb" * 17 + "cccccc" * 15 + "dddddd" * 76 + "eeeeeee") % 97 And since the result ("ffgggggg") % 97 is likely to exceed the limits of a basic calculator, we redo (ff * 76 + ggggggg) % 97 to fit everything within 8 digits.
mamiemando
Moderator
2491175118195 = 97*25682217713 + 34
Is that what you wanted to know?
Good luck
mamiemando
Moderator
More simply, you just need to use a calculator (for example bc on Linux) or a programming language and use the modulo operator (noted % in most programming languages, whether it's C, Java, or PHP... or bc!):
(mando@aldur) (~) $ bc bc 1.06.94 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 2491175118195 % 97 34 97 - 34 63 quit
goldy91
Author
Yes, on the computer I know how to do it, but I would like to know how to do it with a regular calculator?
olivier
What you're trying to calculate seems to be a bank account details. Type "RIB algorithm" into Google and you'll find it.
No, it's not a bank card number, but the key to a social security number...
--
A+ Blux
"Fools will dare anything. That's how we recognize them"
goldy91
Author
OK thanks, I’m starting to understand but Manu, why did you choose 76?
mamiemando
Moderator
To end up with fewer digits than 13, you can already subtract a large multiple of 97 by hand, such as:
97*20000000000
By repeating this procedure, you will quickly reduce the number of digits... (now we have more than 12 digits). In fact, it's almost as simple as performing a long division by hand, just like in elementary school ^^
goldy91
Author
Thank you very much! Actually, my calculator wasn't precise enough and gave me the result in exponential form but only with 10 digits (it was rounded). Do you know how to get the exact result with a regular calculator (Casio graph 35+)?
olivier
If you really don't understand, I'll explain the famous banking algorithm to you. You just have to send me an email at contact@olivierstern.com.