Author 
Message 
William Elliot science forum Guru
Joined: 24 Mar 2005
Posts: 1906

Posted: Fri Jul 21, 2006 12:07 pm Post subject:
Mod computer problem



What is the solution to
n mod 5 = n mod 7 ? 

Back to top 


Pubkeybreaker science forum Guru
Joined: 24 Mar 2005
Posts: 333

Posted: Fri Jul 21, 2006 12:22 pm Post subject:
Re: Mod computer problem



William Elliot wrote:
Quote:  What is the solution to
n mod 5 = n mod 7 ?

"The" solution??? There are infinitely many.
Trivally, n= 1 is a solution. so is n = 2, so is n = 3. so is n =
4..
Now think about the Chinese Remainder Theorem....
(example: n = 74 is a solution; ask yourself what relation the number
74
has to one of the first 4 solutions that I gave) 

Back to top 


Jussi Piitulainen science forum beginner
Joined: 16 Jun 2005
Posts: 11

Posted: Fri Jul 21, 2006 12:53 pm Post subject:
Re: Mod computer problem



William Elliot writes:
Quote:  What is the solution to
n mod 5 = n mod 7 ?

Guessing from the subject line that you want it solved
using a computer, here's a program to collect all k in a
given interval that satisfy the condition:
(define (loopydo k n em)
(if (< k n)
(if (= (modulo k 5) (modulo k 7))
(loopydo (+ k 1) n (cons k em))
(loopydo (+ k 1) n em))
(reverse em)))
Running it for all k from 200, inclusive, to 200,
exclusive, we get a list of solutions:
Quote:  (loopydo 200 200 '())
'(175 174 173 172 171 140 139 138 137 136 105 
104 103 102 101 70 69 68 67 66 35 34 33 32
31 0 1 2 3 4 35 36 37 38 39 70 71 72 73 74 105 106 107
108 109 140 141 142 143 144 175 176 177 178 179)
The general solution seems to be 35k + {0,1,2,3,4} where k
is any integer. 

Back to top 


William Elliot science forum Guru
Joined: 24 Mar 2005
Posts: 1906

Posted: Fri Jul 21, 2006 1:15 pm Post subject:
Re: Mod computer problem



On Fri, 21 Jul 2006, Jussi Piitulainen wrote:
Quote:  William Elliot writes:
What is the solution to
n mod 5 = n mod 7 ?
Guessing from the subject line that you want it solved
using a computer, here's a program to collect all k in a
given interval that satisfy the condition:
No I didn't. n mod 5 is computerese but is tossed around like it is real 
math. Thus since computerese has pretense to math, the guess to make is a
computerese math solution.
Quote:  (define (loopydo k n em)
(if (< k n)
(if (= (modulo k 5) (modulo k 7))
(loopydo (+ k 1) n (cons k em))
(loopydo (+ k 1) n em))
(reverse em)))
Running it for all k from 200, inclusive, to 200,
exclusive, we get a list of solutions:
(loopydo 200 200 '())
'(175 174 173 172 171 140 139 138 137 136 105
104 103 102 101 70 69 68 67 66 35 34 33 32
31 0 1 2 3 4 35 36 37 38 39 70 71 72 73 74 105 106 107
108 109 140 141 142 143 144 175 176 177 178 179)
The general solution seems to be 35k + {0,1,2,3,4} where k
is any integer.
That's why it's not a computer program problem, but a computerese problem, 
depending upon what implementation of a mod n is in vogue That the
program won't ever give the solution set.
x mod 5 = x mod 7
is sheer computerese for there is no Z_5 integers modulus 5
tho by scraping the bottom of the barrel, one could fantasy such.
The solution to the later equation is much more computer language
sensitive than the former equation. 

Back to top 


Bill Dubuque science forum Guru Wannabe
Joined: 04 May 2005
Posts: 236

Posted: Fri Jul 21, 2006 2:10 pm Post subject:
Re: Mod computer problem



William Elliot <marsh@hevanet.remove.com> wrote:
Quote: 
What is the solution to
n mod 5 = n mod 7 ?

HINT n mod a = n mod b, 0 < a <= b
<> n = n mod a + ab/(a,b) Z
If a or b = 0 use Z/a <= Z/b vs. 0 < a <= b
Bill Dubuque 

Back to top 


Google


Back to top 



The time now is Mon Dec 18, 2017 2:47 pm  All times are GMT

