euclidean gcd

This commit is contained in:
Acid
2026-06-08 01:56:36 -04:00
parent 5475d0636f
commit d41b829ea3
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -30,6 +30,7 @@
# Algorithms ω
- [x] Kadane's Algorithm
- [x] Euclidean gcd
# Each category solves different problems:
+10
View File
@@ -0,0 +1,10 @@
package algo
// GCD gives the greatest common factor of two numbers
// EuclideanGCD O(log(n))
func GCD(a int, b int) int {
if b == 0 {
return a
}
return GCD(b, a%b)
}
+1
View File
@@ -4,6 +4,7 @@ package algo
// https://www.youtube.com/watch?v=qj3CjNEKFeM
// MaxSubarray -> returns the max sum of possible sub arrays
// O(n)
func MaxSubarray(array []int) int {
minimum := array[0]
maximum := 0