Questions tagged [mod]

For questions related with the *mod operation*, that can arise in Cryptography, Number Theory, Hashing, etc..

In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus). Given two positive numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder of the Euclidean division of a by n.

437 questions
3
votes
3 answers

How to calculate inverse modular exponentation in c?

I want to take modular inverse(k≥1) of integer and then multiply the result to another integer, as explain in following expression: result=((x^(-k)))*y mod z How can i implement this expression, where k≥1?
AR.5
  • 101
  • 6
3
votes
4 answers

Fastest way to populate an array?

I want to populate an array of size n like this (a very big array): 1 for i = 1, (n/2)+1 2 for i = 2, 3, ... , (n/2) 0 for i = (n/2)+2, ... , n Is the fastest way iterating through 0 to n and using an if statement and % for each one? Like…
Brandan B
  • 464
  • 2
  • 6
  • 21
3
votes
3 answers

Use of OR in bash

I want to assign a variable based upon the modulo of another variable (subject number, in this case), getting a number (representing subject condition) which cycles over N conditions. In other words, I want something very similar to the modular…
Henry Brice
  • 280
  • 1
  • 2
  • 18
3
votes
1 answer

Strange Python Speedup for Modular Inverse

Usually I am lazy and calculate modular inverses as follows: def inv(a,m): return 1 if a==1 else ((a-inv(m%a,a))*m+1)//a print(inv(100**7000,99**7001)) But I was curious to know whether the method of passing more information back, namely the…
user21820
  • 569
  • 8
  • 17
3
votes
1 answer

Solve mod equation in JS

I need to find an x value that satisfied: x * a % m == b x * c % n == d Is there a smarter way to find the solution without iterating all the possibilites ? function solve() { for (x=0;x
Blair d
  • 78
  • 5
3
votes
3 answers

Commutativity of XOR and mod

So when exploring hash functions I noticed the following equation: ((129*N)^prev)%256 = ((129*N)%256)^prev For any number N, prev between 0 and 255. Basically you can drag the mod operation out without changing the result, and it only works for…
Yifan Zhu
  • 35
  • 1
  • 3
2
votes
2 answers

Rust signed modulo unsigned -> unsigned

In (stable) Rust, is there a relatively straightforward method of implementing the following function? fn mod_euclid(val: i128, modulo: u128) -> u128; Note the types! That is, 'standard' euclidean modulus (result is always in the range of [0,…
TLW
  • 1,373
  • 9
  • 22
2
votes
1 answer

How to configure an AzerothCore module to link with the external library?

I am developing a module, which depends on another library(wasmtime). I put files into: modules/mod_wasm/src/include - header files, and modules/mod_mine/src/lib/libwasmtime.a - the compiled library. The problem which I faced is that when I…
Alex Ly
  • 139
  • 5
2
votes
1 answer

Go Mod Download on Raspberry Pi4

Am running into a "cannot execute binary file: Exec format error" when running the following command from the below repository: go mod download…
T3Crypto
  • 43
  • 5
2
votes
1 answer

BigInteger.mod in java equivalent in c#

In java: b1 = new BigInteger("-3896390610386937370574318634931111609708735540536209530871"); b2 = new BigInteger("1000000000000000000000000000000000000000"); // apply mod() method BigInteger result = b1.mod(b2); result =…
jiten
  • 5,128
  • 4
  • 44
  • 73
2
votes
1 answer

What causes an error message like "internal error: failed to find embedded files of..." in go?

I have been working on my branch for a couple of days. Meanwhile the master branch has evolved, so I do git rebase master. The output shows CONFLICTs in some files: Auto-merging vendor/modules.txt CONFLICT (content): Merge conflict in…
Csongor Halmai
  • 3,239
  • 29
  • 30
2
votes
1 answer

How to print 7 when user input 3 without using any condition

So, here is a question when user input 3 than it prints the 7 as output and when user input 7 than it prints 3 as output, but without using any condition and loop. here is what I done.But the problem is i'm using 2 numbers as input but i have to…
TimeToCode
  • 1,458
  • 3
  • 18
  • 60
2
votes
0 answers

How can i add full modding support to my Unity game?

I've played a bit around with Unity-Lua and decidet to add full modding support for my unity game. But it dosn't really work that well... Unity-Lua has some major things missing that i need to add full modding support. Is there a good and easy to…
Flof
  • 99
  • 1
  • 6
2
votes
3 answers

How do I return the amount of times number A can be divided by number B untill it includes a remainder?

for context here is my problem: I have a table of parts. A part is produced from a set of materials, let's call the constant materials variable z. So this table is a table of parts all produced from a set of materials. Each row in this table is a…
test3r123
  • 37
  • 2
  • 9
2
votes
2 answers

Using the Mod Operator for paginating multiple arrays?

I have a number of arrays that I need to pull values from depending on the page that is being requested. Each page needs to be assigned a unique combination of data, so for example: let numbers = ['One', 'Two'] let fruits = ['Apples',…
Tom Dyer
  • 457
  • 2
  • 10
1 2
3
29 30