﻿ oipapio

### greatest common divisor in ocl

How can I write an operation gcd(x : Integer, y : Integer) : Integer which returns the greatest common divisor of two positive integers (the largest integer which divides both of them exactly) in ocl?...Read more

### greatest common divisor - Proving gcd algorithm with Dafny

I'm trying to prove the gcd algorithm with Dafny and it's apparently not that simple. What I have so far (not much indeed) is a functional specification, and Dafny manages to prove that compute_gcd behaves like it. However, when I remove the comments [1], [2] and [3] Dafny failsto prove that the functional specification has the desired properties:function gcd(a: int, b: int) : (result : int) requires a > 0 requires b > 0 // [1] ensures (exists q1:int :: (q1 * result == a)) // [2] ensures (exists q2:int :: (q2 * result == b)) ...Read more

### greatest common divisor - Non Decreasing array with GCD greater than 1

I am given a finite non decreasing arbitrary array. I can add zero or more to the individual elements of the array. What is the minimum additions required to ensure than the gcd of the array is strictly greater than 1? The non decreasing condition should hold....Read more

### greatest common divisor - How to find the GCD of some pairs of numbers of a given set?

I can calculate the GCD of two numbers. given a set S = {1,2,3,4,5} and i have to calculate the GCD of each pair like {1,2} = 1, {1,3} =1 , {1,4} = 1, {1,5} = 1, {2,3} = 1, {2,4} = 2, {2,5} = 1 and so on. I know the O(N^2) solution by just simply calculate the GCD of each pair which will give me TLE in case of big set for 2<=n<= 10^9 or more but i want to learn O(N*sqrt(N) ) solution or more better. i want the GCD of each pair separately....Read more

### greatest common divisor - GCD and LCM relation

The following relation works only for two (3, 12) numbers, it fails to produce the right answer when used for three numbers (3,12,10) . Just wondering if is it my understanding or it is just for two numbers and for me same is true for Euclid algorithm as well.LCM(a, b) = (a x b) / GCD(a,b) or GCD(a,b) = (a x b) / LCM(a, b)...Read more

### greatest common divisor - "Factor" a number into 1-16 products and sum parts

I have a number N (integer 32 bits) that I need to "factor" into 1-16 product and sum parts. Let me explain:For $N = 256$, I want: $(16 \times 16)$For $N = 257$, I want: $(16 \times 16) + 1$For $N = 512$, I want: $(16 \times 16) \times 2$For $N = 530$, I want: $(16 \times 16 \times 2) + (2 \times 9)$For $N = 531$, I want: $(16\times 11 \times 3) + 3$The minor number of sums are better, i.e., products should be preferred.Is there a algorithm for this?...Read more

### greatest common divisor - Old bell rang problem with different starting time

Suppose two bells rang at particular intervals but starting from a different time. First time when it will ring together is ?e.g.,First bell starts at 3, and repeats at regular interval of 5.Second bell starts at 2, and repeats at regular interval of 2.\begin{array}{|c|c|c|c|c|c|}\hlineTime& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hlineBell1& - & -& \checkmark & - & - & - & - &\checkmark\\ \hline Bell2& -& \checkmark& - & \checkmark & - & \checkmark & - &...Read more

### greatest common divisor - Unknown number x, 45•G.C.F(125, x) = L.C.M (125, x)

The least common multiple of 125 and an unknown number x is 45 times their greatest common divisor. Here is what I've tried:Let $\gcd(125,x) = G$ and $\mathrm{lcm}(125,x)=L$.We know$$125 \times x = G \times L \ \text{ and } L = 45G \implies 125x = 45G^2 \implies \frac{25}{9}x = G^2.$$Because $G$ is an integer, so are $x$ and $G^2$, so $9|x$.We know $125\times x = 45G^2$. The two numbers are not relatively prime, because $G \ne 1$. So the number we are looking for should at least be divisible by $5$, and hence by $45$. By trying out mult...Read more

### greatest common divisor - How many positive integers $x \le 3600$ are there such that $\gcd(3600, x)=9$?

I'm trying to answer this question which has a hint: think about $\mathbb Z_{3600}$. I tried to set up a linear equation,$\mod{3600},$ without any success. Not even the factorization of $3600$ gives me any ideas on how to set the problem. Any help?...Read more

### greatest common divisor - Show gcd(a,b) and gcd(a,c) are relatively prime

Let b and c ∈ Z. Suppose that b and c are relatively prime. Show that for all integers a, gcd(a, b) and gcd(a, c) are relatively prime....Read more

### greatest common divisor - Proof that $Z$ is a gcd ring

Recall the general definition of a gcd in a commutative ring $R$.For $a \in R$, $\mathcal D(a)$ is the set of elements that divide $a$ and if $S \subset R$, $\mathcal D(S) = \cap_{s \in S} \mathcal D(s)$We say that $d$ is a gcd of $a$ and $b$ and we write $d \in \gcd(a,b)$ whenever we have $d \in \mathcal D(a,b) \subset \mathcal D(d)$.I would like to prove that, within the ring $\mathbb Z$ every pair of natural numbers has a gcd, that is, $\forall a,b \in \mathbb{N} \quad \gcd(a,b) \neq \emptyset$.Of course, they all have a gcd for the order...Read more

### greatest common divisor - Relation between GCD and LCM

The greatest common divisor of a natural number $n$ and $90$ equals 18. The GCD of $n$ and $120$ equals 12. How can I find the GCD of $n$ and $900$?...Read more
So I was given this question: $n = 2^{16}3^{19}17^{12}$Find $\gcd(n, 40!)$ and $\operatorname{lcm}(n, 40!)$. I understand how to find the GCD and LCM when its two really large numbers (given their prime factorization), But I'm not sure how Id do something like this. Given we're not allowed to use calculators, I assume there is a way to find this.EDITSo I did (floor of each by the way)v2(40!) = 40/2 + 40/4 + 40/8 + 40/16 + 40/32 = 38v3(40!) = 40/3 + 40/9 + 40/27 = 18v17(40!) = 40/17 = 2So what do I do from here?...Read more
### greatest common divisor - Show: $\gcd(a,b)=\gcd(a,c)=1\implies\gcd(a,bc)=1$
This question already has an answer here: If $\gcd(a,b)=1$ and $\gcd(a,c)=1$, then $\gcd(a,bc)=1$ 7 answers...Read more