Sha256: 392535b326ac5b8bcf15652f1c15612117bc67b4a8d365666471f37ff911b1e9

Contents?: true

Size: 714 Bytes

Versions: 363

Compression:

Stored size: 714 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; //!OCLint
        
        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

363 entries across 363 versions & 1 rubygems

Version Path
trackler-2.0.6.20 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.19 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.18 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.17 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.16 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.15 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.14 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.13 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.12 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.11 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.10 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.9 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.8 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.7 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.6 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.5 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.4 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.3 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.2 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
trackler-2.0.6.1 tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m