Created
September 18, 2010 08:45
-
-
Save DaRaFF/585496 to your computer and use it in GitHub Desktop.
Vergleich Java / PHP / Javascript - Teil 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fizzbuzz; | |
public class FizzBuzz { | |
public String getFizzBuzzValueOf(int number){ | |
if(number % 15 == 0){ | |
return "FizzBuzz"; | |
} | |
if(number % 3 == 0){ | |
return "Fizz"; | |
} | |
if(number % 5 == 0){ | |
return "Buzz"; | |
} | |
return String.valueOf(number); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FizzBuzz = { | |
getFizzBuzzValueOf: function(value){ | |
if(value % 15 === 0){ | |
return 'FizzBuzz'; | |
} | |
if(value % 3 === 0){ | |
return 'Fizz'; | |
} | |
if(value % 5 === 0){ | |
return 'Buzz'; | |
} | |
return value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FizzBuzz { | |
public function getFizzBuzzValueOf($number) { | |
if ($number % 15 === 0) { | |
return "FizzBuzz"; | |
} | |
if ($number % 3 === 0) { | |
return "Fizz"; | |
} | |
if ($number % 5 === 0) { | |
return "Buzz"; | |
} | |
return $number; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment