Skip to main content
3 of 6
deleted 18 characters in body; edited title
BCS
  • 205
  • 2
  • 8

BigO of finding the GCD of a set S as a function of sum(S)

The algorithm to be used is:

  • Sort the set into assenting order
  • $x_1 = s_1$
  • $x_i = gdc(x_{i-1},s_i)$
  • $GDC = x_n$

What I'm looking for is expected run time as a function of $\sum_{i\in S}i$

As a starting point $|S| \leq \sum_{i\in S}$ and $gdc$ is $O(ln(n))$ so an upper bound should be $O(n\ln(n))$.

BCS
  • 205
  • 2
  • 8