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

C++ : How to calculate modulo of a number raised to large power?

I am solving a programming problem where I have to print the answer in the format answer mod 10 ^ 9 + 7, where 'answer' is the actual answer to the problem. I have figured out the algorithm to solve the problem, however the caveat is that the answer…
0
votes
1 answer

I am new to C and having trouble with using modulus

On the line that says 'mod = number%iter;', I can replace the modulus with any other operation and it works, but not with modulus. Does anyone know why this is? It just does printf the first two times and then says RUN FAILED (exit value: 1, total…
Doot
  • 555
  • 5
  • 15
0
votes
1 answer

How to shift and cycle characters in python

I want to increase each character's ASCII value, and cycle (wraparound) if value > z. #small chars: for char in string.ascii_lowercase: print factName + '(' + char + ', ' + chr(((ord(char)+key) % ord('z'))) + ').' if key = 3 >> a became d but…
Khaled Alam
  • 885
  • 7
  • 12
0
votes
2 answers

Sum of digits in recursion

Super-sum S of an integer x is defined as x if x is single digit number otherwise Super-sum of x is defined as Super-sum of digit-sum of x. Given two numbers n,k find the Super-sum of the number formed when n is concatenated k times.Note that k is…
Om Sharma
  • 335
  • 1
  • 11
0
votes
3 answers

Mod Operator (%) in C with larger divisor than dividend

Here's my example code in C: int x, y; x = 7 % 10; y = 10 % 7; printf("%d, %d", x, y); It prints: 7, 3 I understand 10 % 7 = 3. I don't understand 7 % 10 = 7. I've tried the same code using float variable and got the same answer. How does mod…
Alex
  • 91
  • 1
  • 2
  • 8
0
votes
0 answers

How can I calculate private key in algorithm Diffie-Hellman with known public key using openssl ?

I have the next formula: 2^x mod p = m; I know the value p and m, how can I calculate x using openssl library ?
VFcdxcv
  • 21
  • 5
0
votes
0 answers

django use spyne lib on apache server response no content

I have developed a web service, using spyne.protocol.soap.soap11 when running In Django command (python manage runserver), it works as expected: 1.I can get wsdl file from $url?wsdl 2.call a web service and get response but when deployed in apache…
zcwcjj
  • 1
  • 5
0
votes
1 answer

Java: simple array and mod

I am trying to solve this problem, in which you enter a number 1-7 which corresponds to the days of the week, (Monday-Sunday) then you add a number between (0-20) and the program returns the day of the week. My current solution works except for…
0
votes
1 answer

How to exit Eclipse without saving

I'm working on a Minecraft mod and I messed up big time, there is errors everywhere. Is there a way to exit Eclipse without saving? I remember exiting Eclipse not too long ago where my workspace didn't have a crap ton of errors.
0
votes
2 answers

Calculating modulo in Java

I can't figure out why the calculation of the mod not going right, I have a=23, b=86609, c=17 where (d=a^c mod b). So the result should be 16559 according to the calculator but I get 49432? public class Mod { public static void main(String[]…
0
votes
1 answer

Remove Dynamic Query string from Apache

I am trying to remove part of dynamic uri from Apache ,tried different rewrite rules but not getting anywhere.I was able to clean url using query string but that deletes anything after accessdenied but we need group part for application to…
Rakesh
  • 35
  • 5
0
votes
3 answers

.Htaccess rewrite to username

I'm a beginner in php and primarily with htaccess part. It's pretty darn confusing. So I have this file :- www.domain.com/profile.php?username=my_username How can I make the above accessible using only :- wwww.domain.com/my_username Any kind of…
xanderpower
  • 49
  • 1
  • 7
0
votes
1 answer

Corner cases while calculating pow(x,n)%d

I've come up with a working code for the above problem, for both positive and negative values of x. And the answers for the majority of situations is correct, however the code fails at a corner case and I can't seem to find what the issue is! What…
vishu
  • 23
  • 7
0
votes
0 answers

Difference between minus and mod operator's computational time

What is the difference between minus and mod operators in terms of time required for computation? I have noticed that mod takes significantly lesser time than minus. For example - Problem statement - I'm incrementing a variable 'x' by 1, 'x' should…
0
votes
4 answers

Mod with negative numbers gives a negative result in Java and C

Let's say I have (-5) mod 8. I tried it in both languages Java and C, and they gave me a -5 result when I was expecting 3. Why is this happening? Can a modulus be negative? And what should I change to get the correct result? Java code public class…
John
  • 81
  • 2
  • 12