数値のさまざまな要素 (「素数」) を持つ配列を表示しようとしています。しかし、int の数値を与える代わりに、常に 0,1,2,3,4,5,... を取得します。
factors.text = @"";
int factorsNumber;
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity:5];
for (factorsNumber=1; factorsNumber<=prime; factorsNumber++) {
if (prime%factorsNumber == 0) {
[array addObject:[NSString stringWithFormat:@"%d", factorsNumber]];
}
}
for (int i = 0; i < [array count]; i++) {
[array replaceObjectAtIndex:1 withObject:@"4"];
NSString *temp = [NSString stringWithFormat:@"%d, ", i, [[array objectAtIndex:i] intValue]];
factors.text = [factors.text stringByAppendingString:temp];
}