-2
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSInteger n = 5;
NSInteger nFactorial = n;
while (n > 1) {
nFactorial = nFactorial * --n;
}
NSLog(@"The factorial of %ld is %ld", (long)n, (long)nFactorial);
return YES;
}
對於此代碼,爲什麼nFactorial必須初始化爲n?爲什麼代碼不能在所有有nFactorial的地方使用n?循環格式化