Code: for(int i = 0 ; i <= 100 ; i++) { if(i % 3 == 0 && i % 5 == 0) { System.out.println("FizzBuzz"); } else if(i % 3 == 0) { System.out.println("Fizz"); } else if(i % 5 == 0) { System.out.println("Buzz"); } else { System.out.println(i); } }
Heh, well done there. I was trying to put a Brainf*ck one together but gave up after well over 3 hours.
Thanx ! :happy: Programming with Brainf*ck requires a lot of patience. While writing this code, many times it came to me "Why should I write it ?". I was ready to give up, but then I thought I had no better way to utilize my time ! But, BF truely f*cks Brain.
The program in Mathematica 7 Code: For[i = 1, i < 101, i++, If[Mod[i, 3] == 0, If[Mod[i, 5] == 0, Print["FIZZBUZZ"], Print["FIZZ"]], If[Mod[i, 5] == 0, Print["BUZZ"], Print[i]]]]
Hi, this is fun Some languages are missing, here is C#: Code: for (int i = 1; i <= 100; i++) { string result = null; if (i % 3 == 0) result += "Fizz"; if (i % 5 == 0) result += "Buzz"; Console.WriteLine("{0}", result ?? i.ToString()); } And here is VB.NET: Code: For i As Integer = 1 To 100 Dim result As String = Nothing If i Mod 3 = 0 Then result += "Fizz" End If If i Mod 5 = 0 Then result += "Buzz" End If Console.WriteLine("{0}", If(result, i.ToString())) Next Also there is a FizzBuzz enterprise edition on GitHub, I laughed my as* out when I found it :happy::happy::happy:
Hi, It is a very old thread but who cares I think it is a good idea to write code in a certain language more than once because as every coder makes a different solution. I am a java programmer and I wrote about fizz buzz game in my blog here: develosapiens.wordpress.com/2015/05/08/fizz-buzz/ I think that code maintenance is more important than the short code. As you can see it in my code -linked before- I created the source in separated files because of easy maintenance requirements. What do you think?