I can't any possible exceptions.

package com.codegym.task.task20.task2025;
import java.util.ArrayList;
import java.util.Date;
/*
Number algorithms
*/
public class Solution {
public static long[] getNumbers(long N) {
if (N < 1) return new long[0];
ArrayList<Long> list = new ArrayList<Long>();
for (int i = 1; i < Math.min(10, N); i++) {
list.add((long) i);
}
int length = 1;
long[] powers = new long[10];
int[] digits = new int[1];
for (int i = 10; i < N; i++) {
String strNum = Integer.valueOf(i).toString();
if (strNum.length() > length) {
length = strNum.length();
for (int base = 0; base < powers.length; base++) {
powers[base] = (long) Math.pow(base, length);
}
digits = new int[length];
}
int sum = 0;
for (int j = 0; j < length; j++) {
digits[j] = strNum.charAt(j) - '0';
}
for (int digit : digits) {
sum += powers[digit];
}
if (sum == i) {
list.add((long) i);
}
}
long[] result = new long[list.size()];
for (int l = 0; l < result.length; l++) {
result[l] = list.get(l);
// System.out.println(result[l]);
}
return result;
}
public static void main(String[] args) {
// getNumbers(2000000);
}
}