Questions tagged [modular-arithmetic]

Modular arithmetic (clock arithmetic) is a system of integer arithmetic based on the congruence relation $a \equiv b \pmod{n}$ which means that $n$ divides $a-b$.

Modular arithmetic (clock arithmetic) is a system of arithmetic of integers. The basic ingredient is the congruence relation $a \equiv b \bmod n$ which means that $n$ divides $a-b$. In modular arithmetic one can add, subtract, multiply and exponentiate but not divide in general. The Euclidean Algorithm, the Chinese Remainder Theorem and Fermat's Little Theorem are important throughout mathematics. Modular exponentiation plays an important role in cryptography nowadays.

10467 questions
164
votes
1 answer

A variation of Fermat's little theorem in the form $a^{n-d}\equiv a$ (mod $p$).

Fermat's little theorem states that for $n$ prime, $$ a^n \equiv a \pmod{n}. $$ The values of $n$ for which this holds are the primes and the Carmichael numbers. If we modify the congruence slightly, $$ a^{n - 1} \equiv a \pmod{n}, $$ the values of…
Tavian Barnes
  • 1,809
  • 2
  • 13
  • 21
124
votes
12 answers

Modular exponentiation by hand ($a^b\bmod c$)

How do I efficiently compute $a^b\bmod c$: When $b$ is huge, for instance $5^{844325}\bmod 21$? When $b$ is less than $c$ but it would still be a lot of work to multiply $a$ by itself $b$ times, for instance $5^{69}\bmod 101$? When $(a,c)\ne1$, for…
user7530
  • 45,846
  • 11
  • 84
  • 142
112
votes
12 answers

Is zero odd or even?

Some books say that even numbers start from $2$ but if you consider the number line concept, I think zero($0$) should be even because it is in between $-1$ and $+1$ (i.e in between two odd numbers). What is the real answer?
112
votes
5 answers

Finding a primitive root of a prime number

How would you find a primitive root of a prime number such as 761? How do you pick the primitive roots to test? Randomly? Thanks
user27617
109
votes
5 answers

Fibonacci number that ends with 2014 zeros?

This problem is giving me the hardest time: Prove or disprove that there is a Fibonacci number that ends with 2014 zeros. I tried mathematical induction (for stronger statement that claims that there is a Fibonacci number that ends in any number…
95
votes
0 answers

Finding primes so that $x^p+y^p=z^p$ is unsolvable in the p-adic units

On my number theory exam yesterday, we had the following interesting problem related to Fermat's last theorem: Suppose $p>2$ is a prime. Show that $x^p+y^p=z^p$ has a solution in $\mathbb{Z}_p^{\times}$ if and only if there exists an integer $a$…
79
votes
3 answers

Mathematicians shocked(?) to find pattern in prime numbers

There is an interesting recent article "Mathematicians shocked to find pattern in "random" prime numbers" in New Scientist. (Don't you love math titles in the popular press? Compare to the source paper's Unexpected Biases in the Distribution of…
77
votes
8 answers

How to find the inverse modulo $m$?

For example: $$7x \equiv 1 \pmod{31} $$ In this example, the modular inverse of $7$ with respect to $31$ is $9$. How can we find out that $9$? What are the steps that I need to do? Update If I have a general modulo equation: $$5x + 1 \equiv 2…
Chan
  • 11,677
  • 17
  • 99
  • 139
74
votes
4 answers

How to calculate $\,(a-b)\bmod n\,$ and $ {-}b \bmod n$

Consider the following expression: (a - b) mod N Which of the following is equivalent to the above expression? 1) ((a mod N) + (-b mod N)) mod N 2) ((a mod N) - (b mod N)) mod N Also, how is (-b mod N) calculated, i.e., how is the mod of a…
J.P.
  • 885
  • 2
  • 8
  • 5
68
votes
7 answers

Why $9$ & $11$ are special in divisibility tests using decimal digit sums? (casting out nines & elevens)

I don't know if this is a well-known fact, but I have observed that every number, no matter how large, that is equally divided by $9$, will equal $9$ if you add all the numbers it is made from until there is $1$ digit. A quick example of what I…
67
votes
5 answers

Does every prime divide some Fibonacci number?

I am tring to show that $\forall a \in \Bbb P\; \exists n\in\Bbb N : a|F_n$, where $F$ is the fibonacci sequence defined as $\{F_n\}:F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}$ $(n=2,3,...)$. How can I do this? Originally, I was trying to show that…
63
votes
7 answers

Compute polynomial $p(x)$ if $x^5=1,\, x\neq 1$ [reducing mod $\textit{simpler}$ multiples]

The following question was asked on a high school test, where the students were given a few minutes per question, at most: Given that, $$P(x)=x^{104}+x^{93}+x^{82}+x^{71}+1$$ and, $$Q(x)=x^4+x^3+x^2+x+1$$ what is the remainder of $P(x)$…
61
votes
8 answers

The last digit of $2^{2006}$

My $13$ year old son was asked this question in a maths challenge. He correctly guessed $4$ on the assumption that the answer was likely to be the last digit of $2^6$. However is there a better explanation I can give him?
50
votes
6 answers

Why does adding a suitable multiple of $9$ always lead to the reverse of the number?

For example: $12$ reversed is $21$ and $12$ + $9$ = $21$. $17$ with the two values swapped is $71$, and $17$ + $9$ + $9$ + $9$ + $9$ + $9$ + $9$ = $71$. Take the number $123$ and add $9$ a total of $22$ times you get $321$, which is the reverse.…
fwefwf
  • 479
  • 4
  • 5
49
votes
2 answers

Fractals using just modulo operation

Let us calculate the remainder after division of $27$ by $10$. $27 \equiv 7 \pmod{10}$ We have $7$. So let's calculate the remainder after divison of $27$ by $7$. $ 27 \equiv 6 \pmod{7}$ Ok, so let us continue with $6$ as the divisor... $ 27 \equiv…
1
2 3
99 100