Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Filter by
Sorted by
Tagged with
2 votes
1 answer
379 views

Tests shows that Python's math.gcd is one order faster than naive Euclidean algorithm implementation: import math from timeit import default_timer as timer def gcd(a,b): while b != 0: ...
Enshin Andrei's user avatar
1 vote
1 answer
71 views

The Euclidean algorithm works as follows: 1.Let a, b be the numbers whose GCD needs to be found. 2.If b = 0, then the number A is the desired GCD. 3.If b > a, then swap the numbers a and b. 4....
degwar's user avatar
  • 19
0 votes
2 answers
199 views

I know that succesive division approach is better in efficiency terms, but I am trying to prove that the substraction approach is also correct for any pair of integers and it will complete always in a ...
alejandrobp's user avatar
-1 votes
3 answers
84 views

Two inputs, number1 = 36 and number2 = 27, are passed to the following code for finding G.C.D of two numbers using Euclidean algorithm. public static int euclideanAlgo(int number1, int number2){ ...
Simon Riley's user avatar
2 votes
1 answer
124 views

I am a new coder and want to write some code to plot various rectangles in matplotlib, taking the animation from this link to demonstrate continued fractions. Namely, I am trying to write a function ...
goodlander01's user avatar
0 votes
1 answer
42 views

I have a two part Question where the first part was to write a code using the Euclidean algorithm function for two numbers. This was the code i made, it works: from math import * def ...
Spuddy's user avatar
  • 19
0 votes
1 answer
1k views

I am currently new in Python and cryptography. I am trying to make a public key of SECP256K1 elliptic curve manually(without related library use), from a random generated private key as I learned. The ...
hib0823's user avatar
0 votes
1 answer
93 views

public static long[] simp (long [] a) { long c = a[0]; long d = a[1]; if ( a[0]<0 ) { a[0] = -1*a[0]; } if (a[1]>a[0]) { long v = a[0]; a[0]=a[1]; ...
Bryan Griffin's user avatar
3 votes
1 answer
1k views

I'm trying to implement Algorithm D from Knuth's "The Art of Computer Programming, Vol 2" in Rust although I'm having trouble understating how to implement the very last step of ...
beeclu's user avatar
  • 31
0 votes
1 answer
161 views

When I give the input as 17, 19: I only get 17, 19, 2 but I expect all numbers below 19 to be given as output. Since we are dealing with primes we should get 1 as GCD. This is my code: a=[] n=int(...
Manikandan Sambasivam's user avatar
0 votes
1 answer
283 views

I have been attempting to understand how to decode the following RS(7,3) code (prim Poly = 1011, prim Elem = 2, b = 2) per the Euclid algo described in WHP 031 previously linked to on the wikipedia ...
Sean's user avatar
  • 35
0 votes
1 answer
738 views

How to correctly calculate the coefficients of the Bezout ratio for the case of negative numbers in the implementation of the extended euclidean algorithm? Here is my code: #include <iostream> #...
Dave Bowman's user avatar
1 vote
0 answers
33 views

I am trying to understand the euclidean TSP algorithm. From most of the explanations available online, we set the value of L = 4n^2. is there any explanation for why L has that value? Here is the ...
ryan chandra's user avatar
0 votes
1 answer
64 views

I'm trying to find GRC for N numbers. For example N = 4, so the 4 numbers is for example 199 199 -199 -199. And im getting StackOverflowException for those numbers. Why? first input number of integers ...
Denys TDV's user avatar
0 votes
0 answers
118 views

I am trying to calculate the euclidean distance in a matrix in C, I saw a similar post and tried it on my own matrix but as it is different I do not know how to make it work. This is my code: #include ...
Ivan Bonilla's user avatar
0 votes
0 answers
365 views

I need to implement an extended Euclidean algorithm for polynomials to get coefficients of Bézout's identity. The problem is I'm struggling with the correct implementation of such a function. I've ...
Jan's user avatar
  • 33
2 votes
4 answers
692 views

I have a Pandas DataFrame of 2 million entries Each entry is a point in a 100 dimensional space I want to compute the Euclidian distance between the N last points and all the others to find the ...
Vincent's user avatar
  • 183
0 votes
0 answers
177 views

Here is the current extended euclidean algorithm I found online : def euclideEtendu(bNombre, aModulo): """ Algorithme d'Euclide étendu, permettant de connaître: PGCD ...
Lukas Apple Fan's user avatar
1 vote
1 answer
544 views

After some experimentation and search, I came up with the following definition: emcd' :: Integer -> Integer -> (Integer,Integer,Integer) emcd' a 0 = (a, 1, 0) emcd' a b = let (g, t, s) = emcd'...
F. Zer's user avatar
  • 1,311
1 vote
1 answer
194 views

After some experimentation and search, I came up with the following definition: emcd' :: Integer -> Integer -> (Integer,Integer,Integer) emcd' a 0 = (a, 1, 0) emcd' a b = let (g, t, s) = emcd'...
F. Zer's user avatar
  • 1,311
1 vote
0 answers
266 views

So about the Extended Euclidean algorithm, the algorithm that finds, a, b, and d in the equation am+bn=d, where m and n are two positive integers, d is their GCD, and a and b are two integers (not ...
Prithvidiamond's user avatar
1 vote
1 answer
439 views

I am trying to make an extended euclidean algorithm with the BigInteger. but I am keeping getting the error that Exception in thread "main" java.lang.ArithmeticException: BigInteger divide ...
user avatar
4 votes
3 answers
242 views

I implemented Euclid's algorithm in the following way at first. euclid x 0 = x euclid x y = euclid y (x `mod` y) The algorithm is tail-recursion, and I expect that it can be intuitively written with ...
いとうかつとし's user avatar
1 vote
1 answer
120 views

Let us say I have a function called my_func(a,b,s,t). Suppose, I want a and b to be passed by value, but I want s and t to be passed by reference. As in, I want to some how pass in let us say (4,5,s',...
Tobias Rieper's user avatar
1 vote
1 answer
251 views

modInverse method of class BigInteger should not be used. I tried and used this method but it does not produce the correct result. Any help would be appreciated. public static int[] extendedgcd(int a, ...
swishy's user avatar
  • 21
1 vote
1 answer
1k views

int gcd(int a, int b) { while(a!=b) { if(a > b) a = a - b; else b = b - a; } return a; } What is the time complexity of this algorithm? ...
sara112's user avatar
  • 13
1 vote
1 answer
460 views

I was wondering if its possible in constant time to calculate the above mentioned goal. I need it to solve a problem on codechef.
Harshit Dubey's user avatar
5 votes
2 answers
1k views

I'm trying to find a way to implement EEA using uint64_t in C, on a system that will not support 128-bit integers. The problem is that it seems like there is always a case where some variable or ...
BadZen's user avatar
  • 4,385
0 votes
2 answers
369 views

Can anyone help explain to me how this code works? I am trying to understand how recursion works and how to write it. def gcdRecur(a, b): ''' a, b: positive integers returns: a positive integer, the ...
B Hok's user avatar
  • 155