#import <Foundation/Foundation.h>
@interface SampleClass:NSObject
/* method declaration */
- (int)odd_count:(int)n;
@end
@implementation SampleClass
- (int) odd_count:(int) n{
//your code here
int odd_counter = 0;
for (int i = 1; i < n; i=i+2) {
// Numbers that are divisible by 2
if (i % 2 != 0)
odd_counter++;
}
return odd_counter;
}
@end
// TODO: replace with your own tests, these are just how-to examples.
// Codewars uses UnitKit unit testing framework.
// See https://github.com/codewars/codewars.com/wiki/UnitKit
@implementation TestSuite
- (void)testCanBeSolvedWithBasicComputations
{
int ret;
SampleClass *sampleClass = [[SampleClass alloc]init];
ret = [sampleClass odd_count:5];
UKIntsEqual(2, ret);
ret = [sampleClass odd_count:15023];
UKIntsEqual(7511, ret);
}
@end