Sha256: 6e3f3cfb0321299736b92f38ff8bb352e2895f37471b0555e5c502ba09766000

Contents?: true

Size: 548 Bytes

Versions: 396

Compression:

Stored size: 548 Bytes

Contents

struct PrimeFactors {

    var number: Int64

    var toArray = [Int64]()

    private func primesFor( _ number: Int64) -> [Int64] {
        var number = number
        var primes = [Int64]()
        var divisor: Int64 = 2

        while number > 1 {
            while number % divisor == 0 {
                primes.append(divisor)
                number /= divisor
            }
            divisor += 1
        }
        return primes
    }

    init(_ value: Int64) {
        self.number = value
        self.toArray = primesFor(value)

    }
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.179 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.178 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.177 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.176 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.175 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.174 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.173 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.172 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.171 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.170 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.169 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.167 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.166 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.165 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.164 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.163 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.162 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.161 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.160 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift