__block int num = 0;
__block void(^fizzbuzz)() = ^{
if (num >= 100)return;
NSLog(@"%@", !(++num % 3) ? !(num % 5) ? @"fizzbuzz" : @"fizz" : !(num % 5) ? @"buzz" : [NSString stringWithFormat:@"%li", num]);
fizzbuzz();
};
fizzbuzz();
More than 5 years have passed since last update.
隣の席の人に再帰キモイというだけだとアレなので、Blocksでfizzbuzz
Posted at
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
33