Questions tagged [modular-arithmetic]

Modular arithmetic is quite a useful tool in number theory. In particular, it can be used to obtain information about the solutions (or lack thereof) of a specific equation.

In mathematics, modular arithmetic (sometimes called clock arithmetic) is a system of arithmetic for integers, where numbers "wrap around" upon reaching a certain value—the modulus. The modern approach to modular arithmetic was developed by Carl Friedrich Gauss in his book Disquisitiones Arithmeticae, published in 1801.

Time-keeping on this clock uses arithmetic modulo 12. A familiar use of modular arithmetic is in the 12-hour clock, in which the day is divided into two 12-hour periods. If the time is 7:00 now, then 8 hours later it will be 3:00. Usual addition would suggest that the later time should be 7 + 8 = 15, but this is not the answer because clock time "wraps around" every 12 hours; in 12-hour time, there is no "15 o'clock". Likewise, if the clock starts at 12:00 (noon) and 21 hours elapse, then the time will be 9:00 the next day, rather than 33:00. Since the hour number starts over after it reaches 12, this is arithmetic modulo 12. 12 is congruent not only to 12 itself, but also to 0, so the time called "12:00" could also be called "0:00", since 0 ≡ 12 mod 12.

324 questions
-1
votes
1 answer

Modular arithmetic AND Eucledian Algorithm

I was studying how to find the modular inverse. Suppose the example is: 27*x is congruent to 1 (mod 392) . Now we have to find x. In the process we write this Equation as: x is congruent to 27^(-1) (mod 392). Here is my confusion does in modular…
-1
votes
3 answers

Created function doesn't work (Python)

I'm fairly new to python, and I tried to use it to make a program to figure out the n-th term to the Stern-Brocot Sequence (you can look that up, and that is why my function is called SBSeq). For some reason, it will not work, and it comes up with…
Qwerp-Derp
  • 487
  • 7
  • 20
-1
votes
2 answers

modular arithmetic-mod of huge numbers in c++

In my short sports programming career i encountered many time Calculating mod of numbers like 26164615615665561165154564545......%(10000007) I have done some research but could only find calculation of mods of numbers in the form (a^b)%c can…
chota bheem
  • 371
  • 3
  • 8
  • 20
-1
votes
2 answers

How to calculate x^y mod z?

I am wondering how to calculate x^y mod z. x and y are very large (can't fit in 64 bit integer) and z will fit 64 bit integer. And one thing don't give answers like x^y mod z is same as (x mod z)^y mod z.
-1
votes
3 answers

Why is 3 modulo 11 equal to 3?

Why is 3 modulo 11 equal to 3? The expression in coding syntax is usually 3 % 11 This is the remainder of dividing 3 by 11, correct? Then the result should be 11 since that would be the remainder. What am I understanding wrong?
Lucas Alanis
  • 1,208
  • 3
  • 15
  • 30
-1
votes
1 answer

C++ GMP: What is the difference between mpq_t and mpf_t >

I am trying to decide which to use with the modular inverse function of GMP, and I can't seem does find the difference between mpq_t and mpf_t. The GMP manual mentions — Function: void mpz_set_q (mpz_t rop, const mpq_t op) — Function: void…
user2059300
  • 361
  • 1
  • 5
  • 17
-2
votes
2 answers

Find all possible sets of variables a, b, c which fits these two equations

Problem Statement -: Suppose "arr" is an array of 101 elements with every value ranging from 1 to 256. Now, we need to select 3 different values a, b, c from arr (basically no repetition which means index_value of a, b, c w.r.t. arr should be…
-2
votes
1 answer

Why does modular exponentiation go wrong when we change datatype of variable "u" from long long to int?

When datatype of variable "u" is long long the modular exponentiation works well but when it is changed to int it gives wrong answers. For example when (2,447,1e9+7) are passed as arguments "long long u" gives 941778035 as the answer but "int u"…
VIr
  • 7
  • 2
-2
votes
1 answer

How to implement modular exponentiation that requires at most double the bytesize of the number that is to be modularly exponentiated in C?

In other words is there such an algorithm for : // powmod(m,e,n) = m^e % n unsigned long long powmod(unsigned long m, unsigned long e, unsigned long long n) that it doesn't overflow for let's say where m = 2^32 - 1, e = 3, n = 2^64 - 1 without gmp…
Nae
  • 14,209
  • 7
  • 52
  • 79
-2
votes
1 answer

For the finite BYTE of Octal numbers

For the finite BYTE of Octal numbers R8 = {0,1,2,3,4,5,6,7,10,1,..,N} The number in BYTE R8: N8 = (78)5 MOD (4008) = ___?______ Can someone please help me answer this. I got 2478, but I am unsure if this is correct. Thank you
groot
  • 31
  • 1
  • 6
-2
votes
1 answer

Modular arithmetic Basic cofusion

I am just learning number theory .When I was reading modular arithmetic I came across this statement : 29 is congruent to 15 (mod 7). So actually this statement actually shows just 29 is congruent to 15 and we are working under mod 7..mod 7 in…
-2
votes
1 answer

Modulur arithmetic logic to reduce calculations

the concept of mod to retain only the remainder instead of the big number. formula to compute: => Summation i=1 to i=N { i%m } Constraint 1 ≤ N ≤ 10^9 1 ≤ m ≤ 10^9 How can modulus used so that we need not to sum up to 10^9 (big Number). Java code…
Hmnshu
  • 230
  • 1
  • 5
  • 13
-2
votes
2 answers

How can we compute modular arithmetic with large divisor and exponent?

Example: (30000000^30000000) mod 40000000 = ? I have been using Euler theory and properties of exponents but still cannot get the answer Anyone know how to calculate this by just theories and simple calculator? My trial is to reduce the exponent of…
Network study
  • 83
  • 1
  • 2
  • 6
-2
votes
1 answer

Two to the power of some large number

Can anyone tell me how to find (2^101100111000)%1000000007 in C? There is a problem in which we have to convert a number into binary(1<=N<=600000) and find 2^(binary representation of N)modulo1000000007.
-2
votes
2 answers

(a^k(p-1)+ b) mod(p) here p is a prime number and a,b,k is an integer greater than 1 and a not divisble by p. Is this value same as (a^b)mod(p)?

According to Fermat's Little theorem a^(p-1) mod(p) is 1. So a^k(p-1) mod(p)will also be 1 by splitting into k parts and apply modulus independently we get '1'. Am I missing something?
Alex
  • 1,178
  • 3
  • 9
  • 24
1 2 3
21
22