Sha256: 3e99b17e57414e7cc69e7cdba96856c9d3b29e4c05f6c98d57c49bc1745e38be

Contents?: true

Size: 532 Bytes

Versions: 68

Compression:

Stored size: 532 Bytes

Contents

#import "PrimeFactorsExample.h"

@implementation PrimeFactors

+ (NSArray <NSNumber *> *)factorsForInteger:(long long)integer {
    
    long long number = integer;
    long long divisor = 2;
    NSMutableArray <NSNumber *> *primes = [[NSMutableArray alloc] init];
    
    while (number > 1) {
        
        while (number % divisor == 0) { // !OCLint
            [primes addObject:[NSNumber numberWithLongLong:divisor]];
            number /= divisor;
        }
        
        divisor++;
    }
    
    return primes;
}

@end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.158 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.157 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.156 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.155 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.154 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.153 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.152 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.151 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.150 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.149 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.148 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.147 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.146 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.145 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.144 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.143 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.142 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.141 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.140 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m