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;
}
时间: 2024-10-17 04:02:37