ricskooo

Untitled

Jan 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class test{
  2.  
  3. public static void main(String[] args) {
  4. fizzBuzz(100);
  5. }
  6.  
  7. private static int fizzBuzz(int n) {
  8. if(n == 0) {
  9. return 0;
  10. }
  11.  
  12. System.out.println(getOutput(n));
  13. return fizzBuzz(n-1);
  14. }
  15.  
  16. private static String getOutput(int n) {
  17. if(n % 3 == 0) {
  18. if(n % 5 == 0) {
  19. return "FizzBuzz";
  20. }
  21. return "Fizz";
  22. } else if( n % 5 == 0) {
  23. return "Buzz";
  24. }
  25.  
  26. return n + "";
  27. }
  28.  
  29. }
Add Comment
Please, Sign In to add comment