Automating Reduction by a Varying Modulus

  • Thread starter Thread starter middleCmusic
  • Start date Start date
  • Tags Tags
    Modulus Reduction
AI Thread Summary
The discussion revolves around automating a specific primality test involving even numbers. The process includes dividing an even number N by 2k, where k is a natural number, and checking if the result is an integer. If it is, the next step is to reduce this integer modulo 2k+1. The goal is to identify and print those values of k (or 2k) for which the result is odd. An example with N = 20 illustrates the procedure, highlighting that only 2k = 2 yields an odd reduction. Participants clarify misunderstandings about the calculations and mention alternative primality testing methods, such as the Sieve of Eratosthenes, but the original poster emphasizes that they are looking for a specific automation solution rather than alternative algorithms. They express a desire for assistance in implementing this logic using Mathematica or Maple, despite their limited programming skills.
middleCmusic
Messages
74
Reaction score
0
Hey guys,

I'm doing some experimenting recently with some primality tests, and I need help figuring out how to automate the following:

Given an even number N, divide by 2k (k \in \mathbb{N}).
If N/2k is an integer, reduce mod 2k+1.
(If N/2k is not an integer, simply move on to the next one.)
Do this for all 2k ≤ N/2.
Then print those k (or 2k, doesn't really matter to me) for which the resulting reduction by the modulus 2k+1 is odd.

EX: N = 20. 20/2 \equiv 1 (mod 3). 20/4 \equiv 0 (mod 5). 20/6 non-integer. 20/8 non-integer. 20/10 \equiv 10 (mod 11).
Print: 2k = 2 (or k = 1), since this is the only odd reduction that was obtained.

If it helps, I have Mathematica and Maple, as well as some basic understanding of LaTeX, but my programming skills are pretty crappy. Thanks in advance!

P. S. I wasn't sure if I should post this in the Computer Science forum, but I figured that it's more of a math topic anyway, and there are bound to be some math people who know how to do this.
 
Technology news on Phys.org
middleCmusic said:
Hey guys,

I'm doing some experimenting recently with some primality tests, and I need help figuring out how to automate the following:

Given an even number N, divide by 2k (k \in \mathbb{N}).
If N/2k is an integer, reduce mod 2k+1.
(If N/2k is not an integer, simply move on to the next one.)
Do this for all 2k ≤ N/2.
Then print those k (or 2k, doesn't really matter to me) for which the resulting reduction by the modulus 2k+1 is odd.

EX: N = 20. 20/2 \equiv 1 (mod 3). 20/4 \equiv 0 (mod 5). 20/6 non-integer. 20/8 non-integer. 20/10 \equiv 10 (mod 11).
I'm not following your logic here. In any case, 20/10 = 2 ##\equiv## 2 (mod 11). There's another way of checking for primes - the Sieve of Eratosthenes.
middleCmusic said:
Print: 2k = 2 (or k = 1), since this is the only odd reduction that was obtained.

If it helps, I have Mathematica and Maple, as well as some basic understanding of LaTeX, but my programming skills are pretty crappy. Thanks in advance!

P. S. I wasn't sure if I should post this in the Computer Science forum, but I figured that it's more of a math topic anyway, and there are bound to be some math people who know how to do this.
 
Oops my bad. That should have been a 2, yeah. The Sieve of Eratosthenes is not what I'm looking for though. I'm not expecting anyone to see my logic in doing this, just wondering if anyone knows how.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top