Skip to content

Instantly share code, notes, and snippets.

@abecus
Created August 26, 2020 19:24
Show Gist options
  • Save abecus/5129fdcce52add1cf5e3ba0062e5739a to your computer and use it in GitHub Desktop.
Save abecus/5129fdcce52add1cf5e3ba0062e5739a to your computer and use it in GitHub Desktop.
def gammaTrialMethod(n):
gamma = 1
count = 0
while n % 2 == 0:
count += 1
n = n // 2
gamma *= pow(2, ceil(count / 2))
for i in range(3, ceil(math.sqrt(n)) + 1, 2):
count = 0
while n % i== 0:
count += 1
n = n // i
gamma *= pow(i, ceil(count / 2))
if n > 2:
gamma *= n
return gamma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment