LoginSignup
3
3

More than 5 years have passed since last update.

隣の席の人に再帰キモイというだけだとアレなので、Blocksでfizzbuzz

Posted at
__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();
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3