0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GoでFizzBuzz

Posted at

FizzBuzzとは

数列を1つずつ表示する。ただし3で割れる数が来たら「Fizz」
5で割れる数が来たら「Buzz」。3でも5でも割れる数が来たら「FizzBuzz」と表示する

ソースコード

package main

import "fmt"

func main() {
	for i := 1; i <= 20; i++ {
		if i%3 == 0 && i%5 == 0 {
			fmt.Println("FizzBuzz")
		} else if i%3 == 0 {
			fmt.Println("Fizz")
		} else if i%5 == 0 {
			fmt.Println("Buzz")
		} else {
			fmt.Println(i)
		}
	}
}

有名すぎて何度もやってるけど違う言語で初めて書くと改めて楽しい。

0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?