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