Author Topic: Can the Blockland Forums pass the Fizz Buzz test?  (Read 2471 times)

Thought it was weird that the OP didn't do one, so here I go.
Code: [Select]
package fizzbuzz;

public class FizzBuzz {

    static void FizzBuzz(int a) {
        if (a%3==0) {
            if(a%5==0) {
                System.out.println("FizzBuzz");
            }
            else {
                System.out.println("Fizz");
            }
        }
        else if(a%5==0) {
            if(a%3==0) {
                System.out.println("FizzBuzz");
            }
            else {
                System.out.println("Buzz");
            }
        }
        else {
            System.out.println(a);
        }
    }
   
    public static void main(String[] args) {
            for(int i=1;i<=100;i++) {
                FizzBuzz(i);
            }
       
    }
}
I know it's redundant to make a new function just to do the math, but I did it for fun ;-;

Code: (Lua) [Select]
for i=1, 100 do
local str = i
if i%3 == 0 then
str = 'Fizz'
end
if i%5 == 0 then
str = 'Buzz'
end
if i%15 == 0 then
str = 'FizzBuzz'
end
print(str)
end