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.159 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.158 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.157 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.156 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.155 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.154 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.153 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.152 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.151 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.150 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.149 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.148 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.147 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.146 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.145 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.144 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.143 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.142 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.141 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift
trackler-2.2.1.140 tracks/swift/exercises/prime-factors/Sources/PrimeFactorsExample.swift