f(n)=f(n-1)+10^n;

 public static void main(String[] args) {
        int n=2017;
        long temp=1;
        for(int i=1;i<n;i++){
            temp+=func(i);
        }
        System.out.println(temp);
    }

    private static long func(int i) {
        // TODO Auto-generated method stub
        long sum;
        if(i==0){
            sum=1;
        }
        else{
            sum=(long) (Math.pow(10, i)+func(i-1));    
        }
        return sum;
    }

相关文章:

猜你喜欢
  • 2022-12-23
  • 2021-12-23
  • 2021-11-10
相关资源
相似解决方案