對於我的應用程序(OSX,不IOS)我有(存儲在容器陣列)這樣生成的幾何序列:目標C數學 - 幾何序列導致
- (void)initContainerFor:(NSInteger)maxRows
{
self.container = [[NSMutableArray alloc] init];
NSInteger start = [self.firstTextFieldValue integerValue];
NSInteger ratio = [self.secondTextFieldValue integerValue];
// ASCENDING
for (NSInteger i = 1; i < (maxRows +1); i++)
{
NSInteger currentValue = start * pow(ratio,i-1);
[self.container addObject:currentValue];
}
}
用戶可以進入「開始」和「比例「整數。如果超出極限(MAX_INT),我想給出反饋。我寫了這個功能:
- (BOOL)maxCheck
{
if ([self.container lastObject] > INT_MAX)
return false;
return true;
}
但是,這似乎不工作。如果我爲比輸入2的起始和200我有這個容器的內容:
Container: (
2,
400,
80000,
16000000,
"-1094967296",
49872896,
1384644608,
2051014656,
"-2113929216",
0
)
請幫助明白我在容器(字符串?),以及如何獲得最大的價值正確的檢查看。
這樣做。謝謝。 –