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
-2
votes
1 answer

How can I repeat a number cycle using mod operator?

I have to loop through 1 <= i <= 20 and every time I mod any i, I want to get a value between 1,2,3. Sorry I have not found any useful resources online. That's why I posted it here. Thanks in advance.
Maisha
  • 45
  • 1
  • 1
  • 8
-2
votes
1 answer

why path = os.Getenv("GOMOD"), path = "" in the project?

I don't known why I can not get the path value. may be there something error or other, path = os.Getenv("GOMOD") // path is "" 1.project go env: .... GOMOD="/home/lu/go/gowork/work/gt/go.mod" ... system go env: ... GOMOD="" ...
Dreamlu
  • 21
  • 2
-2
votes
1 answer

if statement with modulo operator inside for loop

int i; for(i=10;i<=20;i=i+2) if(i%10 <= 5) printf("hello\n"); Why is "hello" printed four times? I expected it to be three times. Is it because of precedence?
-2
votes
2 answers

How to calculate how high x has to be in (x * y) % z before numbers are repeated

I am trying to work out an equation for calculating how many times the code below (y and z are constants) will run before it starts to repeat itself. while (true) { std::cout << (x * y) % z << std::endl; x++ } For example, with a being 100…
8176135
  • 3,755
  • 3
  • 19
  • 42
-2
votes
2 answers

How to apply mod to every element in a list in Haskell

I have a function that produces list of integers to which I would like to apply mod so that no element in the list is greater than 25. For example, the list [6,8,18,28,14,25] should return as [6,8,18,2,14,25]. The code so far is as follows. let…
-2
votes
1 answer

C++: Similar mod operations printing different values

I am trying to perform some custom operation but I noticed the following error. While calculating the value of t, I get desired output but for s I am getting negative values for no reason. #include using namespace std; int…
-2
votes
2 answers

How to convert integer to a list of digital [please read detail in page]

I'd better express this with a example, I'm trying to write a program, say I have a function like this: static List int2List(int l, int base) the input and output should be l=0, base=3, return {1} l=1, base=3, return {2} l=2, base=3,…
Li Wang
  • 13
  • 4
-2
votes
1 answer

why 1 is subtracted from mod where mod =1000000007 in calculation

link of question http://codeforces.com/contest/615/problem/D link of solution is http://codeforces.com/contest/615/submission/15260890 In below code i am not able to understand why 1 is subtracted from mod where mod=1000000007 ll d = 1; ll ans =…
Shashi Kundan
  • 343
  • 1
  • 11
-2
votes
1 answer

Find block number and floor by flat number

Imagine - there's a house with 80 flats. It has 4 floors and 5 blocks. Each block has 4 flats. User is asked to input flat number and Pascal program is supposed to calculate and output flat number. This must be calculated using some kind of formula.…
Gustavs R
  • 61
  • 1
  • 8
-2
votes
2 answers

Solving for multiple Nexts

Having trouble unnesting a function that has multiple variables within the loop that needs to change. I have data that is housed into a a few rows but an annoying amount of columns. I am taking the data and stacking it on top of each other so it can…
Asim Ahmed
  • 83
  • 1
  • 10
-3
votes
1 answer

How do I fix "go: inconsistent vendoring"?

I'm working on a golang project. In a feature branch I'm using a framework that creates a vendor folder. I switched back to the main branch and now when I run: go run main.go I get go: inconsistent vendoring in /path/to/my/project: …
Kosmonaut
  • 2,154
  • 2
  • 18
  • 19
-3
votes
2 answers

How to find inverse of mod when there is an unknown number

I have a formula like: (2x + 3×7 + 5×9 + 7×2) mod 11 = 4 How can I find x in Python? Trial and error is not allowed
STW
  • 1
  • 1
-3
votes
1 answer

Why does my operation of mod (%) on a 2 digit number return zero in python

I've been trying to attempt some leetcode questions as a complete beginner, and a section requires me to convert/return the thousands, hundreds, tens and units place of a number. This is the code in python. class Solution: def intToRoman(self,…
Daniel Chettiar
  • 311
  • 2
  • 9
-3
votes
1 answer

Function for finding all the numbers that divide into 50

for x in range(-50,50): if 50 % x == 0: a.append(x) For a homework question, I have to create a function that will find all the numbers between -50 and 50 that divide into 50 (e.g. 1,2,5,10..) However I run into ZeroDivisionError:…
azulu
  • 15
  • 3
-3
votes
2 answers

Mod operator in C#

Is there a mod operator in C# for RSA algorithm? I've been using % as I thought this could be used as mod, but the answers I get for for c and m are not correct, so I've realised % doesn't work. double e = 13; double d; //decryption …
Rubikted
  • 43
  • 7