Fizz Buzz

Write a program , Output from 1 reach n String representation of numbers .

*
If n yes 3 Multiple of , output “Fizz”;

*
If n yes 5 Multiple of , output “Buzz”;

*
If n At the same time 3 and 5 Multiple of , output “FizzBuzz”.

Examples :
n = 15, return : [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz",
"11", "Fizz", "13", "14", "FizzBuzz" ]
code
class Solution { public List<String> fizzBuzz(int n) { List<String> list = new
ArrayList<>();for(int i=1;i<=n;i++){ if(i % 15 == 0){ list.add("FizzBuzz"); }
else if(i%3==0){ list.add("Fizz"); }else if(i%5==0){ list.add("Buzz"); }else{
list.add(String.valueOf(i)); } }return list; } }

Technology
©2019-2020 Toolsou All rights reserved,
java Four functional interfaces ( a key , simple )os Simple use of module Browser kernel ( understand ) Some East 14 Pay change 16 salary , Sincerity or routine ?HashMap Explain in detail It's unexpected Python Cherry tree (turtle The gorgeous style of Library )html Writing about cherry trees , Writing about cherry trees