How to do modulo calculation? [closed] - math

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I'm following an online course and in one of the lecture it is said that add the first number with the second number modulo of 26.
I don't have the foggiest idea how to do it.
assume the first number 25 and the second number is 5. so how to add them along with modulo of 26 !!!

Modulo arithemtic means that you should use corresponding remainder, not the value itself.
In your case:
5 + 25 (mod 26) == 30 % 26 == 4 // <- "%" is taking remainder after dividing on 26
Whatever operation you do in mod 26, the answer will be in 0..25 range.
Sample code (C#):
int x = 5;
int y = 25;
int mod = 26;
int result = (x + y) % mod;

Related

Multiplying fractional exponents [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I'm doing Tim Roughgarden's Algorithms course and he has a slide with an integer multiplication algorithm.
Whats the rule that makes 10(n/2)a * 10(n/2)c become 10(n)ac ?
What do you do when multiplying fractional exponents like that?
It's based on the First Index Law, where:
am * an = am + n
in your case, the powers add to give n/2 + n/2 = 2n/2 = n
Base is the same so you just add the power of 10 i.e., (n/2) + (n/2) = n. Then it's basic multiplication 10(n)ac= 10(n)ac.

Linear Programming - Absolute value greater than a constant [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
How would you convert the constraint |x| >= 2 so that it would work in a Linear Program (in particular, solving using Simplex).
I understand how to convert |x| <= 2 as that would become x <= 2 and -x <= 2
However the same logic does not work when you have a minimum constant.
There is just no way to shoehorn an equation like |x|>=2 into a pure (continuous) LP. You need to formulate x <= -2 OR x >= 2 which is non-convex. This will require a binary variable making the problem a MIP.
One formulation can be:
x >= 2 - delta*M
x <= -2 + (1-delta)*M
delta in {0,1}
where M is judiciously chosen large number. E.g. if -100<=x<=100 then you can choose M=102.

How does using log10 correctly calculate the length of a integer? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
int length = (int) floor( log10 (float) number ) + 1;
My question is essentially a math question: WHY does taking the log10() of a number, flooring that number, adding 1, and then casting it into an int correctly calculate the length of number?
I really want to know the deep mathematical explanation please!
For an integer number that has n digits, it's value is between 10^(n - 1)(included) and 10^n, and so log10(number) is between n - 1(included) and n. Then the function floor cuts down the fractional part, leaves the result as n - 1. Finally, adding 1 to it gives the number of digits.
Consider that a four-digit number x is somewhere between 1000 <= x < 10000. Taking the log base 10 of all three components gives 3.000 <= log(x, 10) < 4.000. Taking the floor (or int) of each component and adding one gives 4 <= int(log(x, 10))+1 <= 4.
Ignoring round-off error, this gives you the number of digits in x.

Differentiation Math Limits [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
limit x-->3 2x^2 + 7x-15/x-3
What i Simplified
Step 1 : 2x^2 + 10x -3x -15 / x-3
Step 2 : 2x( x + 5)-3( x + 5)/x-3
Step 3 : (2x - 3)(x + 5)/x-3
but unable to move further.. im thinking either the question ix wrong or there ix some trick which im unable to understand
thanx in advance
as x -> 3, the numerator goes to 3 * 8 = 24 and the denominator goes to 0, so the limit goes to +infinity if you approach 3 from the right, and -infinity if you approach 3 from the left
since you didn't specify which direction, the limit does not exist.
try graphing it: https://www.desmos.com/calculator

Number Theory - Factors, HCF and LCM [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
30, 40 and 'n' are such that every number is a factor of the product of other 2 number. If 'n' is a positive
integer , what is the difference between the maximum value of 'n' and the minimum value of 'n'?
Now, since it says that n is a factor of the product of the other 2 numbers, the max value that n can take is 1200 right?
i guess the hcf will give the minimum value of n
Listing the factors of 30 and 40
30 -> 1,2,3,5,6,10,15,30
40 -> 1,2,4,5,8,10,20,40
hcf(30,40) -> 10
Therfore, the difference is 1200-10 => 1190..
But the answer that is given is 1188...where am i going wrong?
Your approach is wrong. The greatest common divisor of 30 and 40 is not your smallest n.
You are looking for the smallest integer n > 0 that satisfies 40*n = 0 (mod 30) and 30*n = 0 (mod 40).
For the first equation, the result is n_1 = 3. For the second equation, we get n_2 = 4. The smallest n to satisfy both equations is the least common multiple of n_1 and n_2 -- in this case, n = 12.
hcf(30,40) -> 12
30=2*3*5
40=2*2*2*5
So, hcf(30,40) -> 3*2*2=12

Resources