From 1a20d13a438eea5d8c5d2c121bebbcb7c4f3868e Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 20:31:26 +0000 Subject: [PATCH 1/2] [Sync Iteration] go/collatz-conjecture/1 --- .../1/collatz_conjecture.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solutions/go/collatz-conjecture/1/collatz_conjecture.go diff --git a/solutions/go/collatz-conjecture/1/collatz_conjecture.go b/solutions/go/collatz-conjecture/1/collatz_conjecture.go new file mode 100644 index 0000000..b3a1486 --- /dev/null +++ b/solutions/go/collatz-conjecture/1/collatz_conjecture.go @@ -0,0 +1,22 @@ +package collatzconjecture +import "errors" +func CollatzConjecture(n int) (int, error) { + num := n + var count int + if n <= 0 { + return 0, errors.New("n is a negative value") + } + if num > 1{ + i:= 0 + for num != 1 { + if num % 2 == 0{ + num = num / 2 + }else{ + num = (3 * num)+1 + } + i++ + } + count = i + } + return count,nil +} From e0b32130b956cf71945c533cd295a7e14b2ed479 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 20:31:27 +0000 Subject: [PATCH 2/2] [Sync Iteration] go/collatz-conjecture/2 --- .../2/collatz_conjecture.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solutions/go/collatz-conjecture/2/collatz_conjecture.go diff --git a/solutions/go/collatz-conjecture/2/collatz_conjecture.go b/solutions/go/collatz-conjecture/2/collatz_conjecture.go new file mode 100644 index 0000000..dcfd3d4 --- /dev/null +++ b/solutions/go/collatz-conjecture/2/collatz_conjecture.go @@ -0,0 +1,22 @@ +package collatzconjecture +import "errors" +func CollatzConjecture(n int) (int, error) { + num := n + var count int + if n <= 0 { + return 0, errors.New("n is a negative value") + } + if num > 1{ + i:= 0 + for num != 1 { + if num & 1 == 0{ + num = num / 2 + }else{ + num = (3 * num)+1 + } + i++ + } + count = i + } + return count,nil +}