Created
October 12, 2021 03:38
-
-
Save TheTurkeyDev/d5578996d515a7d22a9dd18073b36ddf to your computer and use it in GitHub Desktop.
The most cursed FizzBuzz implementation out there....
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
public class FizzBuzzCursed | |
{ | |
//Magic numbers are bad >:( | |
private static final int ZERO = 0; | |
private static final int ONE = 1; | |
private static final int THREE = (int) Math.PI; | |
private static final int FIVE = 5; | |
private static final int ONE_HUNDRED = 100; | |
public static void main(String[] args) | |
{ | |
fizzBuzz(1); | |
} | |
public static void fizzBuzz(int number) | |
{ | |
if(!(number > ONE_HUNDRED)) | |
{ | |
if(isDivisible(number, THREE) && !isDivisible(number, FIVE)) | |
{ | |
System.out.printf("%s", "Fizz"); | |
} | |
else | |
{ | |
if(!isDivisible(number, THREE) && isDivisible(number, FIVE)) | |
{ | |
System.out.printf("%s", "Buzz"); | |
} | |
else | |
{ | |
if(isDivisible(number, THREE)) | |
{ | |
System.out.printf("%s", "Fizz Buzz"); | |
} | |
else | |
{ | |
System.out.printf("%d", number); | |
} | |
} | |
} | |
System.out.println(); | |
fizzBuzz(number + ONE); | |
} | |
} | |
public static boolean isDivisible(int num, int div) | |
{ | |
if(num < ZERO) | |
{ | |
return false; | |
} | |
else | |
{ | |
if(num == ZERO) | |
{ | |
return true; | |
} | |
else | |
{ | |
return isDivisible(Math.abs(-num) + (-div), div); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment