fizz-buzz

https://leetcode.com/problems/fizz-buzz/

public class Solution {
    public List<String> fizzBuzz(int n) {
        List<String> lst= new ArrayList<>();
        for (int i=1; i<=n; i++) {
            if (i % 15 == 0) {
                lst.add("FizzBuzz");
            }
            else if (i % 5 == 0) {
                lst.add("Buzz");
            }
            else if (i % 3 == 0) {
                lst.add("Fizz");
            }
            else {
                lst.add(String.valueOf(i));
            }
        }
        return lst;
    }
}
原文地址:https://www.cnblogs.com/charlesblc/p/5966582.html