Number Theory - Factors, HCF and LCM [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
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

Related

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.

How to do modulo calculation? [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
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;

Convert one modulus value to other [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
Given N = A%B, how to find the value of A%C , where B > C.
You are given value of N and C, but not of A.
Is there any way to find this?
Nope. Consider the following:
A = 19
B = 10
C = 7
==> Given 9, you should get 5.
A = 29
B = 10
C = 7
==> Given 9, you should get 1.
So given the same input, there may be multiple answers.
The modulo operation is one-way: given a mod b = n, all I can say is that a comes from the set of all other integers which, modulo b, equal n.
Let's demonstrate that this is impossible in general, taking B=3, C=2.
n = a mod 3 = 1
=> a is in the set of integers {3x + 1}
so consider, x=1
4 mod 3 = 1, so that works
4 mod 2 = 0
now consider x=2
7 mod 3 = 1, so we can't distinguish 4 from 7 knowing only n and b
7 mod 2 = 1
That is, given b=3 and n=1, you'd have to get two different answers without knowing a.
However, you may consider it's a special case that b and c here are coprime, and in fact are both prime. You can certainly solve this easily for some cases, such as b=4 and c=2.
BTW, further discussion on this is probably better suited to mathoverflow

Project Euler #23 - What does this mean? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
http://projecteuler.net/problem=23
I am not looking for an answer . but can somebody explain me what does this means ?
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the
smallest number that can be written as the sum of two abundant numbers
is 24.
if 12 is smallest abundant number , how come 24 is smallest abundant number that can be written as sum of 2 abundant numbers ?
Problem Text
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n.
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit.
Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
Let n be a number.
If the (sum of proper divisors of n) equals n, then n is perfect.
For example, 6 is perfect, because 1 + 2 + 3 = 6.
If the (sum of proper divisors of n) is less than n, then n is deficient.
For example, 5 is deficient, because 1 < 5.
If the (sum of proper divisors of n) is greater than n, then n is abundant.
As said in the text, for example 12 is abundant, because 1 + 2 + 3 + 4 + 6 > 12.
That said, if 12 is the smallest abundant number and we need to find an abundant number that is a sum of two abundant numbers, the smallest one we can check is the sum of twice the minimal one!
We need A and B such that A + B = C where A, B, C are abundant.
12 is the minimal abundant number and can be both A and B. There's nowhere said that the numbers have to be different. The definitions in Project Euler are pretty well worded, don't assume things that aren't said unless you can prove them. This is math, not a trick question.
Therefore, since A and B can be both 12, the smallest number to look at is 12 + 12 = 24. Which is abundant.

primes and logarithms [theory] [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
I know this is not a mathematical forum but given the bright minds that participate here, i am sure that this question is of interest nevertheless. How would you develop and explain the following statement:
"we can convert the product of a set
of primes into a sum of the logarithms
of the primes by applying logarithms
to both parts of this conjecture"
log(a * b) = log(a) + log(b)
thanks for that OrangeDog and John!
re benefit of introducing logs, OrangeDog is right indeed. It is specific to an exercise from an MIT OpenCourse class. Here's the full details:
There is a cute result from number
theory that states that for
sufficiently large n the product of
the primes less than n is less than or
equal to e^n and that as n grows,
this becomes a tight bound (that is,
the ratio of the product of the primes
to e^n gets close to 1 as n grows).
Computing a product of a large number
of prime numbers can result in a very
large number, which can potentially
cause problems with our computation.
[note: this is what John was referring
to] So we can convert the product of a
set of primes into a sum of the
logarithms of the primes by applying
logarithms to both parts of this
conjecture. In this case, the
conjecture above reduces to the claim
that the sum of the logarithms of all
the primes less than n is less than n,
and that as n grows, the ratio of this
sum to n gets close to 1.
EDIT
given these statements i am, however, unsure about how to apply them i.e.
how do we go from here:
2 x 3 x 5 <= e^7
to
"applying
logarithms to both parts of this
conjecture."
EDIT 2
got it...
2 x 3 x 5 <= e^7
knowing that logarithms are the opposite of powers we can say:
log(2x3x5) <= 7
which is also the same as:
log(2)+log(3)+log(5) <= 7
this only starts to show its "value" when n (in this case 7) gets larger i.e. the 1000th prime or higher

Resources