Sha256: ec954bfddad24ea4e0123ec3d488f4da8bc14f759e41ce0c1659b94248df125f

Contents?: true

Size: 330 Bytes

Versions: 122

Compression:

Stored size: 330 Bytes

Contents

package prime

func Factors(n int64) []int64 {
	factors := []int64{}
	possibleFactor := int64(2)

	for possibleFactor*possibleFactor <= n {
		for n%possibleFactor == 0 {
			factors = append(factors, possibleFactor)
			n /= possibleFactor
		}
		possibleFactor++
	}

	if n > 1 {
		factors = append(factors, n)
	}

	return factors
}

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.97 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.96 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.95 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.94 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.93 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.92 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.91 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.90 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.89 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.88 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.87 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.86 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.85 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.84 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.83 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.82 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.81 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.80 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.79 tracks/go/exercises/prime-factors/example.go