public static int getSum(int num, int quantity) {
int sum = 0;
int[] nums = new int[quantity];
String numStr = num+"";
String tempStr = numStr;
for (int i = 0; i < nums.length; i++) {
for (int k = 0; k < i; k++) {
tempStr += numStr;
}
nums[i] = Integer.parseInt(tempStr);
sum += nums[i];
tempStr = numStr;
}
return sum;
}