“Fizzbuzz” Kode Jawaban

Fizzbuzz Python

def fizz_buzz(num):
    if num % 3 == 0 and num % 5 == 0:
        return "fizzBuzz"
    elif num % 3 == 0:
        return "fizz"
    elif num % 5 == 0:
        return "buzz"
    else:
        return num
Shy Skipper

Fizzbuzz

for (let i = 1, msg; i <= 100; i++, msg = '') {
  if (!(i % 3)) msg += 'Fizz';
  if (!(i % 5)) msg += 'Buzz';
  console.log(msg || i);
}
putsan

Fizzbuzz

for (let i = 1; i <= 100; i++) {
  let f = i % 3 == 0,
    b = i % 5 == 0;
  console.log(f ? (b ? 'FizzBuzz' : 'Fizz') : b ? 'Buzz' : i);
}
Frantic Fish

Fizzbuzz

package main

import "fmt"

func main() {
	for i := 0; i < 100; i++ {
		fmt.Println(i)
		if i % 3 == 0 {
			fmt.Println(i, "Fizz")
		}else if i % 5 == 0{
			fmt.Println(i, "Buzz")
		}
	}
}
gocrazygh

Buzz Fizz

import java.util.Scanner;
public class  SecondFizzBuzz {
    public static void main (String[] args){
        Scanner userInput = new Scanner(System.in);
        int n = userInput.nextInt();
        for (int i = 0; i < n; i++) {
            if (n%3==0&& n%5==0) {
                System.out.println("FizzBuzz");
            }  else if(n%5==0) {
                System.out.println("Buzz");
            }  else if(n%3==0 ) {
                System.out.println("Fizz");
            }
        }

    }
}
Breakable Boar

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya