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.78 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.77 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.76 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.75 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.74 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.73 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.72 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.71 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.70 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.69 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.68 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.67 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.66 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.65 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.64 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.63 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.62 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.61 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.60 tracks/go/exercises/prime-factors/example.go
trackler-2.2.1.59 tracks/go/exercises/prime-factors/example.go