# Questions tagged [modular-arithmetic]

The tag has no usage guidance.

71 questions
Filter by
Sorted by
Tagged with
85 views

### Simplify Mod to subtraction when possible

FullSimplify[Mod[t,10], t>101 && t<109] It's a long shot, but can I get Mathematica to return t-100 or something ...
1k views

### Modular arithmetic in Mathematica? [closed]

I want to implement something like 1 + 1 = 0; i.e., simple modular arithmetic in Mathematica. This seems like it should be a really easy built-in option, but I can'...
74 views

### What is the correct idiom for mapping a 0 value in a modulo n expression back to n?

What is the correct idiom for mapping the $0$ value in a modulo $n$ expression back to $n$. For example if I want to be sure that any integer value maps back to the index for a character in the ...
3k views

### How to solve Mod equation with mathematica [closed]

i'm pretty noob with mathematica but i need to solve an equation: $$c\equiv m^2\pmod n$$ I tried something like ...
301 views

### Faster GCD Implementation

Is there any chance to write a faster GCD than the built-in one in Mathematica? @Mr.Wizard has written one in this question (although it's not for this purpose) which is 6 times slower on a 100k ...
111 views

### Solving a modular equation with a large modulus [duplicate]

I am having trouble solving this equation: $17^n\equiv 1 \mod 640826899755722841329632946651705039010285107743541637238400825304943424424715705661705191669759$ for the smallest integer $n > 0$ I ...
81 views

### Converting an expression to modular arithmetic automatically

I have the expression $\frac{1}{15} \left(-(-1)^n-5\times 2^{n+2}+3\times 2^{2 n+1}+15\right)$ which I want to calculate mod m for a very large n. My current method is to ask for this exression in ...
49 views

### How to apply PolynomialMod to a SparseArray?

I have a list bdrs of SparseArrays, whose entries are polynomials in the variable t with ...
68 views

### Last digits via PowerMod [closed]

Do you have an idea why this produces different results? PowerMod[2003, 2002^2001, 1000] 241 ...
154 views

### Solving an equation for rational modulus 1

I want to solve an system of equations of the form $$\prod_{i=1}^n x_i^{M_{i,k}}=1 \qquad k=1,\ldots,n$$ with complex $x_i$ with constraint $|x_i|=1$ and $M_{i,k}$ integers. This is basically a ...
665 views

### Is there a way to speed up Simplify and/or PolynomialReduce Modulus-> 2?

I'm trying to simplify a series of equations with at most 64 input terms. As the number of terms involved in the equations increase, the runtime seems to grow exponentially. Does anyone know of ways ...
240 views

### Solving for $d$ in $x= E^d \bmod(n)$

With regards to Public Key Cryptography, I have been tasked with the problem of attacking some information given in an assignment and discovered a private key used to digitally sign a message. Known: ...
42 views

### Looping on ranges (Modular iterations)

Is it possible to make the following code modular, so that it works up till depth n, and returns an array of all possible combinations for used{}? ...
50 views

### Get missing cyclic numbers via modulus?

Consider a list of numbers: list = {1,2,3,4,5}; Taking a random set of three of these numbers: ...
58 views

### Putting some calculations together to form an algorithm

Considering these below where n is an odd number, k is also an odd number less than n: <...
90 views

### How can I seperate specific elements from the list? [duplicate]

Possible Duplicate: Question about MapThread and Dynamic I write a function name as inputFieldsList and it returns both ...
49 views

### Finding a solution to a modular problem efficiently

I want to find a naïve hash function of the form Mod[a x + b, 2^p] which would produce a value less or equal to v for all ...
100 views

### Variables defined modulo $\pi$ and avoiding singularities; phase plotting for a map

I have the following $2$-dimensional implicitly defined map ...
53 views

### Function to add two matrices mod 2 [duplicate]

I have: lightstep[m_, gg_] := Which[gg == {1, 1}, m = Mod[m + m, 2]] Then I entered: A = {{1, 1, 0}, {1, 0, 0}, {0, 0, 0}} ...
I would like to produce elements (preferably by Table or For-If commands) that they belong to specific sets. For example I want to write positive integers from 1 to 100 such that they are $2 \pmod 3$, ...