题解 | 数列求和
import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { long index = 9L; List<Long> numbers = new ArrayList<>(); for (int i = 1; i <= 10; i++) { if (i != 1) index = index * 10L + 9; numbers.add(index); } long all = 0L; for (Long number : numbers) { all += number; } System.out.println(all); } }