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.119 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.118 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.117 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.116 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.115 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.114 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.113 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m
trackler-2.2.1.111 tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m