Sha256: 419e59e28414cba556ae2d6572c12067a57b41ab25773ca874444d6b4ae032b0

Contents?: true

Size: 704 Bytes

Versions: 33

Compression:

Stored size: 704 Bytes

Contents

#import "SumOfMultiplesExample.h"

@implementation SumOfMultiples

+ (NSNumber *)toLimit:(NSNumber *)limit inMultiples:(NSArray<NSNumber *> *)multiples {
    NSMutableSet<NSNumber *> *multiplesFound = [[NSMutableSet alloc] init];
    
    for (NSNumber *multiple in multiples) {
        if ([multiple isEqual: @0]) {
            continue;
        }
        
        int x = 1;
        
        while (x * [multiple intValue] < [limit intValue]) {
            [multiplesFound addObject:@(x * [multiple intValue])];
            ++x;
        }
    }
    
    int result = 0;
    
    for (NSNumber *multiple in multiplesFound) {
        result += multiple.intValue;
    }
    
    return @(result);
}

@end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
trackler-2.0.3.7 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.6 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.5 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.4 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.3 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.2 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.1 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.3.0 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.2.0 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.1.2 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.1.1 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.1.0 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.10 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.9 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.8 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.7 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.6 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.5 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.4 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.0.3 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m