Yall fukas need some Fizzbuzz
void fizzbuzz() {
for(int i=0;;i++) {
String s = i%3==0?"fizz":"";
s = i%5!=0?"":"buzz";
System.out.println(s.isEmpty()?i:s);
}
}
>>57998569import java.util.stream.*;
class FizzBuzz{
public static void main(String[] args) {
IntStream
.range(1, 101)
.mapToObj(i -> i%15 == 0 ? "FizzBuzz" :
i% 3 == 0 ? "Fizz" :
i% 5 == 0 ? "Buzz" :
i)
.forEach(System.out::println);
}
}
>>57998569
You have a mistake:
s = i%5!=0?"":"buzz";
must be:
s = i%5!=0?s:"buzz";
1.upto(100){|i|puts'FizzBuzz '[n=i**4%-15,n+13]||i}
>>57998867
That's because when I originally wrote it, I had += instead. Damn.
>>57998569
Is this really fun for anyone here? I've never seen this used in an interview, and it's been done so much that it is a tired meme. I can't understand the mind of who makes these threads.
>>57999860
Noob
>>58000213
It's clear, easy to parse and most importantly performs the actions that OP requested. Problem?
>>58000281
Noob way to write it, therefore you're a noob
>>58000487