eclipse怎么写1 11 101 1001 10001这样的规律题

eclipse怎么写1 11 101 1001 10001这样的规律题

就是一个循环:
当x=1的时候,y=1
当x=2的时候,y=1+10^(2-1)
当x=3的时候,y=1+10^(3-2)
当x=4的时候,y=1+10^(4-2)
……

package com;

public class Main {
    public static void main(String[] args) {
        for (int x = 1; x < 6; x++) {
            long y = (long) ((x == 1 ? 0 : 1) + Math.pow(10, x - 1));
            System.out.print(y + " ");
        }
    }
}

程序输出结果

img