Is this true? (Math)
1. Take an arbitrary number, let's call it arbNum
2. Take an arbitrary multiple of arbNum, let's call it arbMul (must be > arbNum * 2)
3. Subtract arbNum from arbMul and call it resultNaught
4. Divide resultNaught by the all positive integers Z until resultNaught/Z <= arbNum, call this resultSet
5a. Check every number in resultSet, call them elmResult
5b. If elmResult is an integer, and elmResult does not evenly divide arbMul, then arbMul % elmResult = arbNum (where % is the modulus operator.)
Is 5b true?
(Trying to write an encrypted message for my friend to solve.)
[Edited by - anothrguitarist on May 6, 2009 9:35:30 PM]
--------------------Enigmatic Coding
If I follow your directions correctly, then almost. There's a few special cases in the way you've defined it that cause it to break.
arbMul = resultNaught + arbNum, so the left side of your modulus equation can be expressed as (resultNaught + arbNum) % elmResult. Since resultNaught % elmResult = 0, that can be reduced to arbNum % elmResult. If you define elmResult to be strictly greater than arbNum, then arbNum % elmResult = arbNum. However, if you allow the case where elmResult is equal to arbNum (say for example resultNaught is arbNum squared), then arbNum % elmResult = arbNum % arbNum = 0. If you change that inequality to be strict then it should be fine.
arbMul = resultNaught + arbNum, so the left side of your modulus equation can be expressed as (resultNaught + arbNum) % elmResult. Since resultNaught % elmResult = 0, that can be reduced to arbNum % elmResult. If you define elmResult to be strictly greater than arbNum, then arbNum % elmResult = arbNum. However, if you allow the case where elmResult is equal to arbNum (say for example resultNaught is arbNum squared), then arbNum % elmResult = arbNum % arbNum = 0. If you change that inequality to be strict then it should be fine.
I don't understand one through three. Subtracting "arbNum" from a multiple of "arbNum" will just give you a different multiple of "arbNum." Thus, steps one through three seemingly define precisely the same process of taking an arbitrary multiple of "arbNum" without the additional >arbnum*2 stipulation and without doing any subtraction. As for the remaining steps, I don't know offhand. I'll look later if I get a chance, I'm sure I have the necessary facts stored somewhere.
-~-The Cow of Darkness-~-
Quote: Original post by cowsarenotevil
I don't understand one through three. Subtracting "arbNum" from a multiple of "arbNum" will just give you a different multiple of "arbNum." Thus, steps one through three seemingly define precisely the same process of taking an arbitrary multiple of "arbNum" without the additional >arbnum*2 stipulation and without doing any subtraction.
I wondered about that, but it looks like the steps you take for one of those number theory tricks where some of the steps cancel each other out to make things a bit more confusing. I took it as just a round-about way to define two multiples, one just one arbNum greater than the other.
Quote: Original post by Trapper Zoid
If I follow your directions correctly, then almost. There's a few special cases in the way you've defined it that cause it to break.
arbMul = resultNaught + arbNum, so the left side of your modulus equation can be expressed as (resultNaught + arbNum) % elmResult. Since resultNaught % elmResult = 0, that can be reduced to arbNum % elmResult. If you define elmResult to be strictly greater than arbNum, then arbNum % elmResult = arbNum. However, if you allow the case where elmResult is equal to arbNum (say for example resultNaught is arbNum squared), then arbNum % elmResult = arbNum % arbNum = 0. If you change that inequality to be strict then it should be fine.
Step four?
Quote: Original post by cowsarenotevil
I don't understand one through three. Subtracting "arbNum" from a multiple of "arbNum" will just give you a different multiple of "arbNum." Thus, steps one through three seemingly define precisely the same process of taking an arbitrary multiple of "arbNum" without the additional >arbnum*2 stipulation and without doing any subtraction. As for the remaining steps, I don't know offhand. I'll look later if I get a chance, I'm sure I have the necessary facts stored somewhere.
Yeah, it's definitely not in simplest form; see Trapper's comment.
--------------------Enigmatic Coding
Quote: Original post by anothrguitarist
Step four?
Yes. I'm not sure upon reading your explanation if you're allowing the case where resultNaught/Z = arbNum into resultSet. If you're not, then you're fine, but if you are, then the result in 5b might not hold.
Yeah, that's a good point. What I meant by it is that resultNaught/Z should never equal arbNum. You're right.
Thanks for looking through it. I'm about to post code.
Thanks for looking through it. I'm about to post code.
--------------------Enigmatic Coding
So, here's my code. It will take a message and create a string of number pairs. The first number % the second number will yield the ascii character code of that letter. Anyone care to critique my code?
//Encryption 2 Starts Here/*1. Take an arbitrary number, let's call it arbNum2. Take an arbitrary multiple of arbNum, let's call it arbMul (must be > arbNum * 2)3. Subtract arbNum from arbMul and call it resultNaught4. Divide resultNaught by the all positive integers Z until resultNaught/Z <= arbNum, call this resultSet5a. Check every number in resultSet, call them elmResult5b. If elmResult is an integer, and elmResult does not evenly divide arbMul,then arbMul % elmResult = arbNum (where % is the modulus operator.)*/std::vector<int> createModulusPairs(std::vector<int> numbers){ const int OFFSET = 1; std::vector<int> numberPairs; int MUL_MIN = 3; int MUL_MAX = 25; for(unsigned int i = 0; i < numbers.size(); ++i) { int arbNum = numbers; int arbMul = arbNum * (rand() % (MUL_MAX - MUL_MIN) + MUL_MIN + OFFSET); int resultNaught = arbMul - arbNum; std::vector<int> resultSet; resultSet.push_back(resultNaught); int j = 2; while(resultNaught / j > arbNum) { if (resultNaught % j == 0 && arbMul % (resultNaught / j) != 0) resultSet.push_back(resultNaught / j); ++j; } numberPairs.push_back(arbMul); numberPairs.push_back(resultSet[rand() % resultSet.size()]); } return numberPairs;}
--------------------Enigmatic Coding
Counter-example :
1) Take arbNum = 10.
2) Take arbMul = 90.
3) Then resultNaught = arbMul - arbNum = 80.
4) The divisors of 80 are {1, 2, 4, 5, 8, 10, 16, 20, 40, 80}. Now making a slight modification to your algorithm, let 'resultSet' be the elements of the form resultNaught/Z which are integers, so discard all the others, because we only use integers in the last step anyway. Thus resultSet = {1, 2, 4, 5}, since for any divisor q of 80 greater than 5, 80/q <= 10 (Indeed, 80/8 = 10, 80/10 = 8, 80/16 = 4, etc.).
5a) Nothing to do.
5b) Pick elmResult = 4, for example, which is in resultSet. Then 4 does not divide arbMul (because arbMul = 90). However, 90 % 4 = 2, which is different from 10.
That is unless I misunderstood step 4, which I understood as, let:
resultSet = {resultNaught/Z : Z is a positive integer and resultNaught/Z > arbNum}
1) Take arbNum = 10.
2) Take arbMul = 90.
3) Then resultNaught = arbMul - arbNum = 80.
4) The divisors of 80 are {1, 2, 4, 5, 8, 10, 16, 20, 40, 80}. Now making a slight modification to your algorithm, let 'resultSet' be the elements of the form resultNaught/Z which are integers, so discard all the others, because we only use integers in the last step anyway. Thus resultSet = {1, 2, 4, 5}, since for any divisor q of 80 greater than 5, 80/q <= 10 (Indeed, 80/8 = 10, 80/10 = 8, 80/16 = 4, etc.).
5a) Nothing to do.
5b) Pick elmResult = 4, for example, which is in resultSet. Then 4 does not divide arbMul (because arbMul = 90). However, 90 % 4 = 2, which is different from 10.
That is unless I misunderstood step 4, which I understood as, let:
resultSet = {resultNaught/Z : Z is a positive integer and resultNaught/Z > arbNum}
EDIT: Hmm, I think the set in your example is supposed to contain {80/1, 80/2, 80/4, 80/5} = {80, 40, 20, 16}
Then:
90 % 80 = 10
90 % 40 = 10
90 % 20 = 10
90 % 16 = 10
Then:
90 % 80 = 10
90 % 40 = 10
90 % 20 = 10
90 % 16 = 10
--------------------Enigmatic Coding
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement